xsharp.eu • XS0162: Unreachable code detected
Page 1 of 1

XS0162: Unreachable code detected

Posted: Fri Feb 10, 2017 9:11 pm
by George
Hi again.

At compiling time, the previous application generates the error:

C:UsersGeorgeDocumentsVisual Studio 2015ProjectsXSharpApp1Form1 Methods.prg(68,2): warning XS0162: Unreachable code detected

at the RETURN statement (end of METHOD Listen_EntryPoint).

When I remove the RETURN statement, it compiles the project without errors.

I am attaching here a project showing the issue.

thanks and regards
George
App1.zip
(12.87 KiB) Downloaded 76 times

XS0162: Unreachable code detected

Posted: Fri Feb 10, 2017 9:55 pm
by FFF
George,
EDIT: as Chris said.

(sorry, didn't really "read" the output, time to shut down eyes & computer ;)
fetched your code, doubleclicked the solution, VS2015 Community Edition loaded, "Build" - some seconds, "1 succeeded 0 fails". Looked for the Listen meth, "Return" is there. ??

XS0162: Unreachable code detected

Posted: Fri Feb 10, 2017 10:09 pm
by Chris
Hi George,

I think this is a correct warning, isn't it? In the code there is a DO WHILE TRUE without an EXIT statement, so execution will never go out of this loop, and any code after it will not execute, thus the warning.

Chris

XS0162: Unreachable code detected

Posted: Fri Feb 10, 2017 10:47 pm
by George
Chris,

>I think this is a correct warning, isn't it? In the code there is a DO WHILE TRUE without an EXIT statement, so execution will never go out of this loop, and any code after it will not execute, thus the warning.

That's true: Putting a conditional EXIT or RETURN inside the LOOP, it compiles.
But, the loop must be always present to listen into the System.Threading.Tasks.Task created by CreateParallelSocketServerTask Method.
And finally, calling the:
SELF:oSocketServer:Close()
at program's exit, the Task will be terminated. Right ?

regards
George

XS0162: Unreachable code detected

Posted: Fri Feb 10, 2017 10:52 pm
by George
Hi Karl,

when you compiled (with X# of course) didn't you see the warning for the line:
68 (Form1 Methods.prg) ?

I am using the beta 0.9.

regards
George

XS0162: Unreachable code detected

Posted: Sat Feb 11, 2017 12:53 am
by Chris
Hi George,

I'd assume that indeed this will terminate it, but on the other hand I don't have experience on socket programming, so better not take my assumption for a fact! :)

Maybe someone with experience in the area can help..

Chris