Compiler bug?
Steven Schveighoffer
schveiguy at yahoo.com
Wed Jul 16 13:58:59 PDT 2008
"Steven Schveighoffer" wrote
> "Jarrett Billingsley"wrote
>> "Steven Schveighoffer" wrote
>>>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.
>
> sweet deal :) So if Walter wants me to debug this, maybe he can send me a
> copy of obj2asm for free :)
>
>>
>> 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.
>
> Yeah, I had lots of trouble with the debugger. But the printout alone is
> proof that it is failing.
>
>>
>> But if it makes you feel any better (?), this is definitely a
>> g. -inline should *never* change the behavior of code. Bugzilla it if
>> it hasn't been already.
>
> OK, so should I just attach all tango source used to the bug report? :P
>
> I suppose I could try and whittle it down.
>
> I'm just really surprised this is the first case. It makes me think that
> there is something really 'moons-are-aligned-properly' about the way
> everything is compiled.
>
> -Steve
Got to a minimal Phobos-based case:
http://d.puremagic.com/issues/show_bug.cgi?id=2232
-Steve
More information about the Digitalmars-d-learn
mailing list