October 29, 2004 optimization of struct argument | ||||
---|---|---|---|---|
| ||||
Hi, When I compile the following code with no optimization, the code works good. But when I compile with optimization, the code works strange. <code> struct S { ubyte a, b, c, d; } int hoge(S s) { printf("%x\n", s); return 0; } int main() { for (int i = 0; i < 1; i++) { S s; s.a = 1; s.b = 2; s.c = 3; s.d = 4; hoge(s); } return 0; } </code> This bug occurs on Windows and Linux. You can reproduce this bug in the following way: > dmd d.d gcc d.o -o d -lphobos -lpthread -lm > ./d 4030201 > dmd -O d.d gcc d.o -o d -lphobos -lpthread -lm > ./d 1 |
October 31, 2004 Re: optimization of struct argument | ||||
---|---|---|---|---|
| ||||
Posted in reply to shinichiro.h | added to dstress as: svn://svn.kuehne.cn/dstress/run/struct_14.d svn://svn.kuehne.cn/dstress/run/struct_15.d Thomas shinichiro.h schrieb: > Hi, > > When I compile the following code with no optimization, the code works good. But when I compile with optimization, the code works strange. > > <code> > struct S { > ubyte a, b, c, d; > } > > int hoge(S s) { > printf("%x\n", s); > return 0; > } > > int main() { > for (int i = 0; i < 1; i++) { > S s; > s.a = 1; > s.b = 2; > s.c = 3; > s.d = 4; > hoge(s); > } > return 0; > } > </code> > > This bug occurs on Windows and Linux. You can reproduce this bug in the following way: > > > dmd d.d > gcc d.o -o d -lphobos -lpthread -lm > > ./d > 4030201 > > dmd -O d.d > gcc d.o -o d -lphobos -lpthread -lm > > ./d > 1 |
Copyright © 1999-2021 by the D Language Foundation