fbpx
Welcome, Guest
Username: Password: Remember me
  • Page:
  • 1

TOPIC: XS0162: Unreachable code detected

XS0162: Unreachable code detected 2 years 5 months ago #1161

  George's Avatar Topic Author George Offline Posts: 91
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.

XS0162: Unreachable code detected 2 years 5 months ago #1163

  FFF's Avatar FFF Offline Posts: 619
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. ??

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

Last edit: by FFF. Reason: incorrect/-complete

XS0162: Unreachable code detected 2 years 5 months ago #1164

  Chris's Avatar Chris Offline Posts: 1226
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.

XS0162: Unreachable code detected 2 years 5 months ago #1166

  George's Avatar Topic Author George Offline Posts: 91
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.

XS0162: Unreachable code detected 2 years 5 months ago #1167

  George's Avatar Topic Author George Offline Posts: 91
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.

XS0162: Unreachable code detected 2 years 5 months ago #1169

  Chris's Avatar Chris Offline Posts: 1226
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.

  • Page:
  • 1