www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 5955] New: core.demangle fail to parse NaN and Infinity.

reply d-bugmail puremagic.com writes:
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



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
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=5955


kennytm gmail.com changed:

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



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
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=5955






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
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=5955


kennytm gmail.com changed:

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



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: -------
Jun 19 2011