fbpx

XS0162: Unreachable code detected

  • George Theopoulos
  • George Theopoulos's Avatar Topic Author
  • Offline
More
1 year 11 months ago #1 by George Theopoulos
XS0162: Unreachable code detected was created by George Theopoulos
Hi again.

At compiling time, the previous application generates the error:

C:\Users\George\Documents\Visual Studio 2015\Projects\XSharp\App1\Form1 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

File Attachment:

File Name: App1.zip
File Size:13 KB
Attachments:

Please Log in or Create an account to join the conversation.

More
1 year 11 months ago - 1 year 11 months ago #2 by Karl Faller
Replied by Karl Faller on topic XS0162: Unreachable code detected
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. ??
Last edit: 1 year 11 months ago by Karl Faller. Reason: incorrect/-complete

Please Log in or Create an account to join the conversation.

More
1 year 11 months ago #3 by Chris Pyrgas
Replied by Chris Pyrgas on topic XS0162: Unreachable code detected
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

XSharp Development Team
chris(at)xsharp.eu

Please Log in or Create an account to join the conversation.

  • George Theopoulos
  • George Theopoulos's Avatar Topic Author
  • Offline
More
1 year 11 months ago #4 by George Theopoulos
Replied by George Theopoulos on topic XS0162: Unreachable code detected
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

Please Log in or Create an account to join the conversation.

  • George Theopoulos
  • George Theopoulos's Avatar Topic Author
  • Offline
More
1 year 11 months ago #5 by George Theopoulos
Replied by George Theopoulos on topic XS0162: Unreachable code detected
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

Please Log in or Create an account to join the conversation.

More
1 year 11 months ago #6 by Chris Pyrgas
Replied by Chris Pyrgas on topic XS0162: Unreachable code detected
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

XSharp Development Team
chris(at)xsharp.eu

Please Log in or Create an account to join the conversation.