digitalmars.D.bugs - [Issue 4323] New: std.demangle incorrectly handles template floating point numbers
- d-bugmail puremagic.com (48/48) Jun 15 2010 http://d.puremagic.com/issues/show_bug.cgi?id=4323
- d-bugmail puremagic.com (15/15) May 08 2011 http://d.puremagic.com/issues/show_bug.cgi?id=4323
- d-bugmail puremagic.com (34/34) May 08 2011 http://d.puremagic.com/issues/show_bug.cgi?id=4323
- d-bugmail puremagic.com (7/7) May 08 2011 http://d.puremagic.com/issues/show_bug.cgi?id=4323
- d-bugmail puremagic.com (12/12) Jun 19 2011 http://d.puremagic.com/issues/show_bug.cgi?id=4323
http://d.puremagic.com/issues/show_bug.cgi?id=4323 Summary: std.demangle incorrectly handles template floating point numbers Product: D Version: D1 & D2 Platform: Other OS/Version: Mac OS X Status: NEW Severity: normal Priority: P2 Component: Phobos AssignedTo: nobody puremagic.com ReportedBy: doob me.com According to the ABI spec the mangled form of template floating point numbers looks like this: Value: e HexFloat HexFloat: N HexDigits P Exponent HexDigits P Exponent But std.demnalge doesn't seem to handle the exponent, it doesn't handle the 'P'. The unittests that test this are also incorrect. The first one looks like this: mangled form: _D4test58__T9factorialVde67666666666666860140VG5aa5_68656c6c6fVPvnZ9factorialf demangled form: float test.factorial!(double 4.2, char[5] \"hello\"c, void* null).factorial As far as I can see the mangled form doesn't follow the spec or what dmd produces. module test; float factorial (T...) () { return float.init; } void main () { factorial!(4.2, "hello", null); } Compiling the above code and running the "nm" command on the resulting binary shows that "factorial" with the above given values is mangled as: _D4test57__T9factorialVde8666666666666667PN1VAyaa5_68656c6c6fVPvnZ9factorialFZf After all the 6s the is a 7 and then a P. In the std.demangle unittest the P is missing, also at the end of the mangled name is a Z which is missing in the unittest. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Jun 15 2010
http://d.puremagic.com/issues/show_bug.cgi?id=4323 kennytm gmail.com changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |kennytm gmail.com With core.demangle it now resolves _D4test57__T9factorialVde8666666666666667PN1VAyaa5_68656c6c6fVPvnZ9factorialFZf into: float test.factorial!(8.400000, "hello", null).factorial() The only problem is the floating point number is 2 times bigger than the expected. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
May 08 2011
http://d.puremagic.com/issues/show_bug.cgi?id=4323 kennytm gmail.com changed: What |Removed |Added ---------------------------------------------------------------------------- Keywords| |patch, wrong-code Component|Phobos |druntime The demangler forgot to put the 'p', making the exponent part totally ignored. Also, using the '%f' format makes floating point number that is extremely small becomes 0.00000. I think '%g' is more suitable. diff --git a/src/core/demangle.d b/src/core/demangle.d index 6d37633..b2ab00d 100644 --- a/src/core/demangle.d +++ b/src/core/demangle.d -368,6 +368,7 private struct Demangle next(); } match( 'P' ); + tbuf[tlen++] = 'p'; if( 'N' == tok() ) { tbuf[tlen++] = '-'; -386,7 +387,7 private struct Demangle tbuf[tlen] = 0; debug(info) printf( "got (%s)\n", tbuf.ptr ); val = strtold( tbuf.ptr, null ); - tlen = snprintf( tbuf.ptr, tbuf.length, "%Lf", val ); + tlen = snprintf( tbuf.ptr, tbuf.length, "%Lg", val ); debug(info) printf( "converted (%.*s)\n", cast(int) tlen, tbuf.ptr ); put( tbuf[0 .. tlen] ); } -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
May 08 2011
http://d.puremagic.com/issues/show_bug.cgi?id=4323 https://github.com/D-Programming-Language/druntime/pull/15 -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
May 08 2011
http://d.puremagic.com/issues/show_bug.cgi?id=4323 kennytm gmail.com changed: What |Removed |Added ---------------------------------------------------------------------------- Version|D1 & D2 |D1 Fixed for D2 in https://github.com/D-Programming-Language/druntime/commit/f9ce91691092281a2c07699cfd68fd1297c7b37f. Not sure about D1. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Jun 19 2011