Compiler bug?
Steven Schveighoffer
schveiguy at yahoo.com
Wed Jul 16 08:41:56 PDT 2008
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.
-Steve
More information about the Digitalmars-d-learn
mailing list