Thread overview | |||||||||
---|---|---|---|---|---|---|---|---|---|
|
May 29, 2005 Mysterious char[] bug (dmd 0.125) | ||||
---|---|---|---|---|
| ||||
<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. |
June 04, 2005 Re: Mysterious char[] bug (dmd 0.125) | ||||
---|---|---|---|---|
| ||||
Posted in reply to zwang Attachments:
| 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
|
June 05, 2005 Re: Mysterious char[] bug (dmd 0.125) | ||||
---|---|---|---|---|
| ||||
Posted in reply to Thomas Kühne | 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>
|
June 05, 2005 Re: Mysterious char[] bug (dmd 0.125) | ||||
---|---|---|---|---|
| ||||
Posted in reply to zwang | 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 |
June 11, 2005 Re: Mysterious char[] bug (dmd 0.125) | ||||
---|---|---|---|---|
| ||||
Posted in reply to zwang Attachments:
| 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 |
June 16, 2005 Re: Mysterious char[] bug (dmd 0.125) | ||||
---|---|---|---|---|
| ||||
Posted in reply to zwang | "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. |
June 16, 2005 Re: Mysterious char[] bug (dmd 0.125) | ||||
---|---|---|---|---|
| ||||
Posted in reply to Walter | 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.
|
Copyright © 1999-2021 by the D Language Foundation