[Issue 4323] std.demangle incorrectly handles template floating point numbers
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Sun May 8 02:49:25 PDT 2011
http://d.puremagic.com/issues/show_bug.cgi?id=4323
kennytm at gmail.com changed:
What |Removed |Added
----------------------------------------------------------------------------
Keywords| |patch, wrong-code
Component|Phobos |druntime
--- Comment #2 from kennytm at gmail.com 2011-05-08 02:45:28 PDT ---
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: -------
More information about the Digitalmars-d-bugs
mailing list