digitalmars.D.bugs - optimization of struct argument
- "shinichiro.h" <s31552 mail.ecc.u-tokyo.ac.jp> Oct 29 2004
- "Thomas Kuehne" <thomas-dloop kuehne.cn> Oct 31 2004
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
./d
dmd -O d.d
./d
Oct 29 2004
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
./d
dmd -O d.d
./d
Oct 31 2004








"Thomas Kuehne" <thomas-dloop kuehne.cn>