digitalmars.D.learn - Compiler bug?
- Steven Schveighoffer (30/30) Jul 16 2008 I think I found a bug in the compiler. This bug seems to have affected ...
- Jarrett Billingsley (9/38) Jul 16 2008 You have to buy the EUP to get the windows version of obj2asm, lol.
- Jarrett Billingsley (7/8) Jul 16 2008 Another option might be the OpenWatcom disassembler tool, now that I thi...
- Steven Schveighoffer (11/60) Jul 16 2008 sweet deal :) So if Walter wants me to debug this, maybe he can send me...
- Bill Baxter (4/7) Jul 16 2008 When NRVO was introduced there were some bugs that appeared that sound
- Steven Schveighoffer (4/68) Jul 16 2008 Got to a minimal Phobos-based case:
- dennis luehring (2/2) Jul 16 2008 ida pro is the best - and the 4.9 version is free for non-commercial use
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
Jul 16 2008
"Steven Schveighoffer" <schveiguy yahoo.com> wrote in message news:g5l4s4$1285$1 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.
Jul 16 2008
"Jarrett Billingsley" <kb3ctd2 yahoo.com> wrote in message news:g5lha8$20s2$1 digitalmars.com...You have to buy the EUP to get the windows version of obj2asm, lol.Another option might be the OpenWatcom disassembler tool, now that I think about it. http://www.openwatcom.org/index.php/Main_Page I'm almost certain the linker works with OMF, so the disassembler should be able to disassemble the objects that DMD produces.
Jul 16 2008
"Jarrett Billingsley"wrote"Steven Schveighoffer" wrotesweet deal :) So if Walter wants me to debug this, maybe he can send me a copy of obj2asm for free :)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.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 ug. -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
Jul 16 2008
Steven Schveighoffer wrote: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.When NRVO was introduced there were some bugs that appeared that sound similar to yours, but I think all the ones reported were fixed. --bb
Jul 16 2008
"Steven Schveighoffer" wrote"Jarrett Billingsley"wroteGot to a minimal Phobos-based case: http://d.puremagic.com/issues/show_bug.cgi?id=2232 -Steve"Steven Schveighoffer" wrotesweet deal :) So if Walter wants me to debug this, maybe he can send me a copy of obj2asm for free :)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.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
Jul 16 2008
ida pro is the best - and the 4.9 version is free for non-commercial use http://www.hex-rays.com/idapro/idadownfreeware.htm
Jul 16 2008