Bug 7566 – compiler works incorrectly when debug{} statements are present, ver 2.057
Status
RESOLVED
Resolution
INVALID
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2012-02-23T07:43:00Z
Last change time
2012-02-23T18:15:51Z
Assigned to
nobody
Creator
tbolsh
Comments
Comment #0 by tbolsh — 2012-02-23T07:43:33Z
$ more d_compiler_bug_around_debug.d
#!/usr/bin/rdmd -debug
import std.stdio;
void main(){
bool dummy_flag = false;
if( dummy_flag )
debug{ writeln("debug print 1"); }
writeln( "Some real action ..." );
debug{ writeln("debug print 2"); }
else{
writeln( "Some other action ");
}
}
$ ./d_compiler_bug_around_debug.d
Some real action ...
debug print 2
$ dmd -v
DMD32 D Compiler v2.057
Copyright (c) 1999-2011 by Digital Mars written by Walter Bright
Documentation: http://www.digitalmars.com/d/2.0/index.html
...
Comment #1 by tbolsh — 2012-02-23T07:46:31Z
If debug statements are removed - compiler behave as expected:
$ more d_compiler_bug_around_debug.d
#!/usr/bin/rdmd -debug
import std.stdio;
void main(){
bool dummy_flag = false;
if( dummy_flag )
writeln("debug print 1");
writeln( "Some real action ..." );
writeln("debug print 2");
else{
writeln( "Some other action ");
}
}
$ ./d_compiler_bug_around_debug.d
./d_compiler_bug_around_debug.d(10): found 'else' instead of statement
./d_compiler_bug_around_debug.d(13): unrecognized declaration
Failed: dmd -debug -v -o- './d_compiler_bug_around_debug.d' -I'.' >./d_compiler_bug_around_debug.d.deps
Comment #2 by bugzilla — 2012-02-23T12:30:38Z
I'm not sure what you're expecting, but the compiler behaves correctly in your first example.
Comment #3 by tbolsh — 2012-02-23T13:07:19Z
I am expecting to see somewhat like
./d_compiler_bug_around_debug.d(10): found 'else' instead of statement
./d_compiler_bug_around_debug.d(13): unrecognized declaration
when compiled with debug key and nothing when compiled without.
I believe my expectations are correct ...
Comment #4 by yebblies — 2012-02-23T18:15:51Z
(In reply to comment #3)
> I am expecting to see somewhat like
>
> ./d_compiler_bug_around_debug.d(10): found 'else' instead of statement
> ./d_compiler_bug_around_debug.d(13): unrecognized declaration
>
> when compiled with debug key and nothing when compiled without.
> I believe my expectations are correct ...
The following is valid syntax:
debug { } else { }
Although I don't think I've ever wanted to use an else block on a debug statement.