Compiler bug?

Jarrett Billingsley kb3ctd2 at yahoo.com
Wed Jul 16 12:14:16 PDT 2008


"Steven Schveighoffer" <schveiguy at yahoo.com> wrote in message 
news:g5l4s4$1285$1 at digitalmars.com...
>I think I found a bug in the compiler.  This bug seems to have affected the 
>two versions I tried of dmd (1.024 and 1.033), so it's been in there a 
>while.
>
> However, it's a very weird bug.
>
> I have a function that looks like this (for those who are interested, this 
> is from tango.io.Path):
>
> Time modified (char[] name)
> {
>        return timeStamps(name).modified;
> }
>
> the timeStamps function returns a collection of 3 Time structs, which 
> indicate the modified, created, and accessed time for a file named 'name'.
>
> However, the result is corrupt.  I know this because I'm printing the time 
> in the timeStamps function, and it is different than the time returned.
>
> In examining the entire flow of the code, I can find nothing wrong.
>
> This only happens with the -inline switch of dmd.
>
> If I rewrite the function in the following way, the problem goes away(!):
>
> Time modified (char[] name)
> {
>  auto ts = timeStamps(name);
>        return ts.modified;
> }
>
> Now, I wanted to create a minimal case (without all of Tango that this 
> program uses), but I'm having difficulty.  So I wanted to inspect the 
> assembly, but I'm on windows, and there is no obj2asm in the dmd 
> directory. So I can't figure out what the compiler is doing differently. 
> I'm not sure where to begin.  Walter, is this enough info for you to look 
> into this?  I can send you the object file and source file if you want to 
> see how dmd generated the code.

You have to buy the EUP to get the windows version of obj2asm, lol.

Another way to disassemble is to compile in debug info with -g, and step 
through in a debugger, like WinDbg (shudder), ddbg (OK), or VS6 (yay).  I'm 
not sure how -g behaves with -inline though.

But if it makes you feel any better (?), this is definitely a bug.  -inline 
should *never* change the behavior of code.  Bugzilla it if it hasn't been 
already. 




More information about the Digitalmars-d-learn mailing list