[Issue 3736] New: corrupted struct returned by function with optimizations (-O)
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Sat Jan 23 10:02:05 PST 2010
http://d.puremagic.com/issues/show_bug.cgi?id=3736
Summary: corrupted struct returned by function with
optimizations (-O)
Product: D
Version: 2.030
Platform: Other
OS/Version: Windows
Status: NEW
Keywords: wrong-code
Severity: regression
Priority: P2
Component: DMD
AssignedTo: nobody at puremagic.com
ReportedBy: spam at extrawurst.org
--- Comment #0 from Stephan Dilly <spam at extrawurst.org> 2010-01-23 10:02:04 PST ---
building the following code with -O corrupts the return value of getFoo.
sorry could not reduce it more:
import std.stdio;
struct Foo
{
float x=0;
}
struct Bar
{
Foo p0;
Foo p1;
}
Bar a = {Foo(0),Foo(400)};
Foo getFoo(Foo _pos)
{
Bar stillok = a;
float d0 = (a.p0.x - _pos.x);
float d1 = (a.p0.x - _pos.x);
if( d0 > d1 )
{
return stillok.p0;
}
else
{
return stillok.p1;
}
}
void main()
{
writefln("%s", getFoo( Foo(100) ).x );
}
// prints 6.91062e-39 under dmd2039
// prints 3.2372e-39 under dmd2030
--
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
More information about the Digitalmars-d-bugs
mailing list