www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - Mysterious char[] bug (dmd 0.125)

reply zwang <nehzgnaw gmail.com> writes:
<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
next sibling parent reply =?ISO-8859-1?Q?Thomas_K=FChne?= <thomas-dloop kuehne.THISISSPAM.cn> writes:
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
parent reply zwang <nehzgnaw gmail.com> writes:
Thomas Kühne wrote:
 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
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>
Jun 04 2005
parent Dave <Dave_member pathlink.com> writes:
In article <d7tlh1$j0c$1 digitaldaemon.com>, zwang says...
Thomas Kühne wrote:
 
 Can you reproduce this bug without using Phobo's functions?
 
 Thomas
 
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>
Also, compiling w/ -O gives the expected output (both Linux and Win32). - Dave
Jun 04 2005
prev sibling next sibling parent =?ISO-8859-1?Q?Thomas_K=FChne?= <thomas-dloop kuehne.THISISSPAM.cn> writes:
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
prev sibling parent reply "Walter" <newshound digitalmars.com> writes:
"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
parent zwang <nehzgnaw gmail.com> writes:
Walter wrote:
 "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.
Great! I'm wondering where the bug lurks.
Jun 16 2005