digitalmars.D.bugs - Mysterious char[] bug (dmd 0.125)
-
zwang
(20/20)
May 29 2005
- =?ISO-8859-1?Q?Thomas_K=FChne?= (3/23) Jun 04 2005 Can you reproduce this bug without using Phobo's functions?
- zwang (18/49) Jun 04 2005 I can reproduce the bug without calling std.utf.encode:
- Dave (3/26) Jun 04 2005 Also, compiling w/ -O gives the expected output (both Linux and Win32).
- =?ISO-8859-1?Q?Thomas_K=FChne?= (6/26) Jun 11 2005 Added to DStress as
- Walter (3/4) Jun 16 2005 It's already been reported and the fix will go out in the next update.
- zwang (2/11) Jun 16 2005 Great! I'm wondering where the bug lurks.
<code> import std.stdio; const char[] culprit;//#2 void f(...){ char[] s; void putc(dchar c){ std.utf.encode(s, c); } std.format.doFormat(&putc, _arguments, _argptr); //foreach(char ch; s){} //#9 writef(s); } void main(){ f("mystery"); } </code> The program above does not display "mystery" as expected. The string can be displayed when line #2 is removed or when line #9 is uncommented, both seemingly irrelevant. I've smelt something fishy in dmd's code generator.
May 29 2005
zwang wrote:<code> import std.stdio; const char[] culprit;//#2 void f(...){ char[] s; void putc(dchar c){ std.utf.encode(s, c); } std.format.doFormat(&putc, _arguments, _argptr); //foreach(char ch; s){} //#9 writef(s); } void main(){ f("mystery"); } </code> The program above does not display "mystery" as expected. The string can be displayed when line #2 is removed or when line #9 is uncommented, both seemingly irrelevant. I've smelt something fishy in dmd's code generator.Can you reproduce this bug without using Phobo's functions? Thomas
Jun 04 2005
Thomas Kühne wrote:zwang wrote:I can reproduce the bug without calling std.utf.encode: <code> import std.stdio; const char[] culprit;//#2 void f(...){ char[] s; void putc(dchar c){ s ~= c; } std.format.doFormat(&putc, _arguments, _argptr); //foreach(char ch; s){} //#9 writef(s); } void main(){ f("mystery"); } </code><code> import std.stdio; const char[] culprit;//#2 void f(...){ char[] s; void putc(dchar c){ std.utf.encode(s, c); } std.format.doFormat(&putc, _arguments, _argptr); //foreach(char ch; s){} //#9 writef(s); } void main(){ f("mystery"); } </code> The program above does not display "mystery" as expected. The string can be displayed when line #2 is removed or when line #9 is uncommented, both seemingly irrelevant. I've smelt something fishy in dmd's code generator.Can you reproduce this bug without using Phobo's functions? Thomas
Jun 04 2005
In article <d7tlh1$j0c$1 digitaldaemon.com>, zwang says...Thomas Kühne wrote:Also, compiling w/ -O gives the expected output (both Linux and Win32). - DaveCan you reproduce this bug without using Phobo's functions? ThomasI can reproduce the bug without calling std.utf.encode: <code> import std.stdio; const char[] culprit;//#2 void f(...){ char[] s; void putc(dchar c){ s ~= c; } std.format.doFormat(&putc, _arguments, _argptr); //foreach(char ch; s){} //#9 writef(s); } void main(){ f("mystery"); } </code>
Jun 04 2005
zwang wrote:<code> import std.stdio; const char[] culprit;//#2 void f(...){ char[] s; void putc(dchar c){ std.utf.encode(s, c); } std.format.doFormat(&putc, _arguments, _argptr); //foreach(char ch; s){} //#9 writef(s); } void main(){ f("mystery"); } </code> The program above does not display "mystery" as expected. The string can be displayed when line #2 is removed or when line #9 is uncommented, both seemingly irrelevant. I've smelt something fishy in dmd's code generator.Added to DStress as http://dstress.kuehne.cn/run/o/odd_bug_03_A.d http://dstress.kuehne.cn/run/o/odd_bug_03_B.d http://dstress.kuehne.cn/run/o/odd_bug_03_C.d Thomas
Jun 11 2005
"zwang" <nehzgnaw gmail.com> wrote in message news:d7d2kq$1mc$1 digitaldaemon.com...The program above does not display "mystery" as expected.It's already been reported and the fix will go out in the next update.
Jun 16 2005
Walter wrote:"zwang" <nehzgnaw gmail.com> wrote in message news:d7d2kq$1mc$1 digitaldaemon.com...Great! I'm wondering where the bug lurks.The program above does not display "mystery" as expected.It's already been reported and the fix will go out in the next update.
Jun 16 2005