Thread overview
[Bug 81] New: incorrect statement is not reachable in 0.18
Apr 03, 2006
d-bugmail
Apr 03, 2006
Brad Roberts
Apr 03, 2006
Derek Parnell
Apr 03, 2006
d-bugmail
April 03, 2006
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@puremagic.com
        ReportedBy: lane@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@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@wookies:~$ gdc -fdebug -fversion=bar -Wall example.d warning - example.d:21: statement is not reachable


-- 

April 03, 2006
Have you tried this with dmd itself?  It's unlikely that this is a gdc specific bug.
April 03, 2006
On Mon, 3 Apr 2006 02:56:33 +0000 (UTC), d-bugmail@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@puremagic.com
>         ReportedBy: lane@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@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@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
April 03, 2006
http://d.puremagic.com/bugzilla/show_bug.cgi?id=81


lane@downstairspeople.org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |DUPLICATE




------- Comment #2 from lane@downstairspeople.org  2006-04-03 01:07 -------
It's a frontend bug.  Sorry.  I'll check against dmd in the future.

*** This bug has been marked as a duplicate of 82 ***


--