Goto skips declaration

MatheusBN m at gmail.com
Sun Nov 4 22:16:55 UTC 2018


On Sunday, 4 November 2018 at 22:09:31 UTC, MatheusBN wrote:
> I'm not the OP, but I could reproduce!
>
> Example 1 - Problem:
>
> void main(){
>     goto Q;
>     int x;
>     Q:
>     writeln("a");
> }
>
> Error: source_file.d(4): Error: goto skips declaration of 
> variable source.main.x at source_file.d(5)
>
>
> Example 2 - Now if you add brackets:
>
> void main(){
>     {
>         goto Q;
>          int x;
>     }
>     Q:
>     writeln("a");
>
>
> It will work.
>
> MatheusBN.

By the way I forgot the link: https://rextester.com/OUJHT98447

MatheusBN


More information about the Digitalmars-d mailing list