Re: Is this a bug? +goto

2018-11-06 Thread MatheusBN via Digitalmars-d-learn
On Tuesday, 6 November 2018 at 05:46:40 UTC, Jonathan M Davis wrote: On Monday, November 5, 2018 7:55:46 PM MST MatheusBN via Digitalmars-d-learn wrote: On Tuesday, 6 November 2018 at 01:55:04 UTC, Jonathan M Davis wrote: >> And I found a bit strange that in such code, since "x&qu

Re: Is this a bug? +goto

2018-11-05 Thread MatheusBN via Digitalmars-d-learn
On Tuesday, 6 November 2018 at 01:05:04 UTC, Neia Neutuladh wrote: In C++, if you skip over `int i = 10;` it's an error, but not if you skip over `int i;`. In fact I agree with that rule more than the D one to be honest. Since It isn't initialized and never used, I think a warning should be e

Re: Is this a bug? +goto

2018-11-05 Thread MatheusBN via Digitalmars-d-learn
On Tuesday, 6 November 2018 at 01:04:46 UTC, Stanislav Blinov wrote: ...Even if you don't see any explicit use, it doesn't mean the compiler doesn't see an implicit one. Sorry I don't think that I follow that. How a compiler could see an use when it's not being used/invoked on a program like i

Re: Is this a bug? +goto

2018-11-05 Thread MatheusBN via Digitalmars-d-learn
On Tuesday, 6 November 2018 at 01:55:04 UTC, Jonathan M Davis wrote: And I found a bit strange that in such code, since "x" is never used, why it isn't skipped. It's skipped right over. The goto jumps out of the scope, and the line with int x; is never run. In fact, if you compile with -w o

Re: Is this a bug? +goto

2018-11-05 Thread MatheusBN via Digitalmars-d-learn
On Tuesday, 6 November 2018 at 00:13:52 UTC, Stanislav Blinov wrote: But here it's fine: void main(){ { goto Q; S x; } // <--- Q: writeln("a"); } because goto jumps over both initialization *and* destruction, i.e. neither would even be performed. I see b

Re: Is this a bug? +goto

2018-11-05 Thread MatheusBN via Digitalmars-d-learn
On Tuesday, 6 November 2018 at 00:14:26 UTC, Jonathan M Davis wrote: On Monday, November 5, 2018 4:54:59 PM MST MatheusBN via Digitalmars-d-learn wrote: Hi, I posted this in another thread but without any response. This code: void main(){ goto Q; int x; Q: writeln(&q

Is this a bug? +goto

2018-11-05 Thread MatheusBN via Digitalmars-d-learn
Hi, I posted this in another thread but without any response. This code: void main(){ goto Q; int x; Q: writeln("a"); } Gives me this error: "source_file.d(4): Error: goto skips declaration of variable source.main.x at source_file.d(5)" Now, if I add a pair of brackets: