[Bug 81] New: incorrect statement is not reachable in 0.18

Derek Parnell derek at psych.ward
Sun Apr 2 21:47:21 PDT 2006


On Mon, 3 Apr 2006 02:56:33 +0000 (UTC), d-bugmail at puremagic.com wrote:

> http://d.puremagic.com/bugzilla/show_bug.cgi?id=81
> 
>            Summary: incorrect statement is not reachable in 0.18
>            Product: GDC
>            Version: unspecified
>           Platform: PC
>         OS/Version: Linux
>             Status: NEW
>           Severity: minor
>           Priority: P2
>          Component: glue layer
>         AssignedTo: braddr at puremagic.com
>         ReportedBy: lane at downstairspeople.org
> 
> This is from the version hosted at http://www.puremagic.com/~braddr/d/gdc/
> 
> ======= example.d =======
> 
> module example;
> 
> import std.c.stdio, std.string;
> 
> void foo() {
>   printf( toStringz( "foo!" ) );
> }
> 
> void bar() {
>   printf( toStringz( "bar!" ) );
> }
> 
> void main( char[][] args ) {
>   switch( args[1] ) {
>     debug {
>       case "--foo":
>       case "-f":
>         foo();
>         break;
>     }
>     version( bar ) {
>       case "--bar":
>       case "-b":
>         bar();
>         break;
>     }
>     default:
>       foo();
>       bar();
>       break;
>   }
> }
> 
> ======== ========
> 
> lane at wookies:~$ gdc --version
> gdc (GCC) 4.0.3 (gdc 0.18-alpha-1, using dmd 0.148)
> Copyright (C) 2006 Free Software Foundation, Inc.
> This is free software; see the source for copying conditions.  There is NO
> warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
> 
> lane at wookies:~$ gdc -fdebug -fversion=bar -Wall example.d
> warning - example.d:21: statement is not reachable

I was under the impression that the things enclosed in debug{} and
version{} blocks had to be complete expressions. In you example, you
enclose the 'case:' keyword and I'm not sure that is supposed to be
allowed.

For example, this works ...

 void main( char[][] args ) {
   switch( args[1] ) {
       case "--foo":
       case "-f":
     debug {
         foo();
     }
         break;
       case "--bar":
       case "-b":
     version( bar ) {
         bar();
     }
         break;
     default:
       foo();
       bar();
       break;
   }
 }

Anyhow, I'm sure that a better message would have helped this situation.

-- 
Derek
(skype: derek.j.parnell)
Melbourne, Australia
"Down with mediocracy!"
3/04/2006 2:44:27 PM



More information about the D.gnu mailing list