www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [DMD 0.101] Version statement without else clause within if crashes

reply Burton Radons <burton-radons shaw.ca> writes:
This code causes the compiler to crash:

     void foo ()
     {
         if (x)
             version (none)
                 foo;
     }

The specification doesn't say what a collapsed version/debug statement 
turns into, so I don't know how it's supposed to behave.
Sep 19 2004
next sibling parent reply Lars Ivar Igesund <larsivar igesund.net> writes:
Burton Radons wrote:

 This code causes the compiler to crash:
 
     void foo ()
     {
         if (x)
             version (none)
                 foo;
     }
 
 The specification doesn't say what a collapsed version/debug statement 
 turns into, so I don't know how it's supposed to behave.

I think this leads to an incorrect program, as version (none) becomes nothing: void foo () { if (x) } which is wrong because there is no statement following if (x). The compiler shouldn't crash, though. Lars Ivar Igesund
Sep 19 2004
parent Stewart Gordon <Stewart_member pathlink.com> writes:
In article <cikkvs$1f9n$1 digitaldaemon.com>, Lars Ivar Igesund 
says...

 Burton Radons wrote:
 
 This code causes the compiler to crash:
 
     void foo ()
     {
         if (x)
             version (none)
                 foo;
     }


 void foo ()
 {
 if (x)
 }
 
 which is wrong because there is no statement following if (x).  The 
 compiler shouldn't crash, though.

The D versioning system isn't a text preprocessor. As such, it is pointless to try and think of version blocks as reducing to textual nothingness. Rather, it reduces to semantic nothingness, an effective 'nop' statement. Another way to think of it is by imagining that there are braces: void foo() { if (x) { version (none) { foo; } } } The statement forms if ( Expression ) Statement if ( Expression ) { Statement } are identical in effect, By converting to the latter, it is easy to see the result of version reduction. Stewart.
Sep 28 2004
prev sibling parent reply "Walter" <newshound digitalmars.com> writes:
It's fixed now. It turns into:

    if (x) ;
Sep 19 2004
parent reply Stewart Gordon <Stewart_member pathlink.com> writes:
In article <cil2q3$1l6i$1 digitaldaemon.com>, Walter says...
It's fixed now. It turns into:

    if (x) ;

You mean you've changed it so that that's valid D syntax? Stewart.
Sep 27 2004
parent "Walter" <newshound digitalmars.com> writes:
"Stewart Gordon" <Stewart_member pathlink.com> wrote in message
news:cj9ltc$16k1$1 digitaldaemon.com...
 In article <cil2q3$1l6i$1 digitaldaemon.com>, Walter says...
It's fixed now. It turns into:

    if (x) ;

You mean you've changed it so that that's valid D syntax?

No. I meant: if (x) { }
Sep 30 2004