Is this a bug? +goto

Stanislav Blinov stanislav.blinov at gmail.com
Tue Nov 6 01:04:46 UTC 2018


On Tuesday, 6 November 2018 at 00:38:01 UTC, MatheusBN wrote:
> 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 but at same time I found a bit confusing, because in this 
> case we're just adding a new scope to fix the issue, and like I 
> said to Jonathan, I thought that "x" wouldn't be initialized 
> since it is never used.

It's not as simple as that, that's why I specifically showed the 
destructor case. Even if you don't see any explicit use, it 
doesn't mean the compiler doesn't see an implicit one.





More information about the Digitalmars-d-learn mailing list