Thread overview
[Issue 5955] New: core.demangle fail to parse NaN and Infinity.
May 08, 2011
kennytm@gmail.com
May 08, 2011
kennytm@gmail.com
May 08, 2011
kennytm@gmail.com
Jun 19, 2011
kennytm@gmail.com
May 08, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=5955

           Summary: core.demangle fail to parse NaN and Infinity.
           Product: D
           Version: D2
          Platform: Other
        OS/Version: Mac OS X
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody@puremagic.com
        ReportedBy: kennytm@gmail.com


--- Comment #0 from kennytm@gmail.com 2011-05-08 02:51:15 PDT ---
For example, the program

-------------------------------------------
module y;
template TTTTTTTTTT(float v) {
    void TTTTTTTTTT() {
    }
}
void main() {
    TTTTTTTTTT!1.0f();
    TTTTTTTTTT!(float.nan)();
    TTTTTTTTTT!(float.infinity)();
}
-------------------------------------------

generates the symbols

_D1y22__T10TTTTTTTTTTVfeINFZ10TTTTTTTTTTFZv _D1y22__T10TTTTTTTTTTVfeNANZ10TTTTTTTTTTFZv _D1y23__T10TTTTTTTTTTVfe8PN3Z10TTTTTTTTTTFZv

which the demangler can only recognize 1 out of 3:

void y.__T10TTTTTTTTTTVfeINFZ.TTTTTTTTTT()    // fail
void y.__T10TTTTTTTTTTVfeNANZ.TTTTTTTTTT()    // fail
void y.TTTTTTTTTT!(1).TTTTTTTTTT()            // ok

-- 
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=5955


kennytm@gmail.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |patch


--- Comment #1 from kennytm@gmail.com 2011-05-08 03:15:42 PDT ---
Patch:


@@ -354,6 +354,14 @@ private struct Demangle
             tbuf[tlen++] = '-';
             next();
         }
+        if( 'I' == tok() ) // INF
+        {
+            match( "INF" );
+            bool isNegative = tlen == 1;
+            debug(info) printf( "got (%sINF)\n", isNegative ? "N" : "" );
+            put( isNegative ? "-real.infinity" : "real.infinity" );
+            return;
+        }
         tbuf[tlen++] = '0';
         tbuf[tlen++] = 'X';
         if( !isHexDigit( tok() ) )
@@ -362,6 +370,19 @@ private struct Demangle
         tbuf[tlen++] = '.';
         next();

+        if( 'N' == tok() ) // NAN
+        {
+            if( tbuf[0] == '-' && tbuf[3] == 'A' )
+            {
+                next();
+                debug(info) printf( "got (NAN)\n" );
+                put( "real.nan" );
+                return;
+            }
+            else
+                error( "Unexpected 'N'" );
+        }
+
         while( isHexDigit( tok() ) )
         {
             tbuf[tlen++] = tok();

-- 
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=5955



--- Comment #2 from kennytm@gmail.com 2011-05-08 09:47:01 PDT ---
druntime pull request #15

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: -------
June 19, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=5955


kennytm@gmail.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED


--- Comment #3 from kennytm@gmail.com 2011-06-19 11:38:56 PDT ---
https://github.com/D-Programming-Language/druntime/commit/6d43b5187a6ab0650ecf037d97a2c0ccac584265

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------