digitalmars.D.bugs - [Issue 2756] New: Bad code generation for pure nothrow math functions
- d-bugmail puremagic.com (40/40) Mar 24 2009 http://d.puremagic.com/issues/show_bug.cgi?id=2756
- d-bugmail puremagic.com (13/13) Mar 24 2009 http://d.puremagic.com/issues/show_bug.cgi?id=2756
- d-bugmail puremagic.com (4/4) Mar 27 2009 http://d.puremagic.com/issues/show_bug.cgi?id=2756
- d-bugmail puremagic.com (9/9) Apr 01 2009 http://d.puremagic.com/issues/show_bug.cgi?id=2756
http://d.puremagic.com/issues/show_bug.cgi?id=2756 Summary: Bad code generation for pure nothrow math functions Product: D Version: 2.025 Platform: PC OS/Version: Windows Status: NEW Keywords: wrong-code Severity: normal Priority: P2 Component: DMD AssignedTo: bugzilla digitalmars.com ReportedBy: clugdbug yahoo.com.au Bad code generation occurs when the module is called 'std.math' in a module statement, and the signature is exactly 'pure nothrow double XXX(double)' or 'pure nothrow float XXX(float)', and the parameter is a compile-time constant. I suspect this is related to the special treatment of std.math.sqrt(), allowing it to be evaluated at compile time. ---------------- MINIMAL TEST CASE: ---------------- module std.math; pure nothrow double food(double x){ return 2.0;} void main() { assert( food(1.0) == 2.0 ); } ---------------- FURTHER INFO: ---------------- module std.math; import std.stdio; pure nothrow float foof(float x){return 2.0;} pure nothrow double food(double x){ return 2.0;} pure nothrow real foor(real x) { return 2.0; } void main() { writefln(foor(1.0)); // writes 2. OK. writefln(food(1.0)); // writes -0 !! writefln(foof(1.0)); // writes 0 !! } --
Mar 24 2009
http://d.puremagic.com/issues/show_bug.cgi?id=2756 clugdbug yahoo.com.au changed: What |Removed |Added ---------------------------------------------------------------------------- Keywords| |patch Patch: builtin.c line 62 -------- if (ident == Id::_sqrt) // add this line builtin = BUILTINsqrt; -------- --
Mar 24 2009
http://d.puremagic.com/issues/show_bug.cgi?id=2756 Eh, that's an embarassing one! --
Mar 27 2009
http://d.puremagic.com/issues/show_bug.cgi?id=2756 bugzilla digitalmars.com changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED Resolution| |FIXED Fixed DMD 2.027 --
Apr 01 2009