www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 4925] New: [ICE] segfault with module-scope assert(0)

reply d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=4925

           Summary: [ICE] segfault with module-scope assert(0)
           Product: D
           Version: D1 & D2
          Platform: All
        OS/Version: All
            Status: NEW
          Keywords: ice-on-valid-code, patch
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: rsinfu gmail.com


--- Comment #0 from Shin Fujishiro <rsinfu gmail.com> 2010-09-23 13:34:12 PDT
---
The following code crashes the compiler:

const int a = (assert(0), 1);

Patch:
--- src/expression.c
+++ src/expression.c
   -5695,8 +5695,11    Expression *AssertExp::semantic(Scope *sc)
     }
     if (e1->isBool(FALSE))
     {
-        FuncDeclaration *fd = sc->parent->isFuncDeclaration();
-        fd->hasReturnExp |= 4;
+        if (sc->parent && sc->parent->isFuncDeclaration())
+        {
+            FuncDeclaration *fd = sc->parent->isFuncDeclaration();
+            fd->hasReturnExp |= 4;
+        }

         if (!global.params.useAssert)
         {   Expression *e = new HaltExp(loc);

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Sep 23 2010
parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=4925


Walter Bright <bugzilla digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |bugzilla digitalmars.com
         Resolution|                            |FIXED


--- Comment #1 from Walter Bright <bugzilla digitalmars.com> 2010-09-27
19:57:26 PDT ---
http://www.dsource.org/projects/dmd/changeset/694

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