www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 3493] New: Segfault(cast.c) Forward reference with type inference, D1 only.

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

           Summary: Segfault(cast.c) Forward reference with type
                    inference, D1 only.
           Product: D
           Version: 1.050
          Platform: Other
        OS/Version: Windows
            Status: NEW
          Keywords: ice-on-valid-code
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: clugdbug yahoo.com.au


--- Comment #0 from Don <clugdbug yahoo.com.au> 2009-11-10 02:03:37 PST ---
This is the second bug reported in bug 2080.

const bar = foo;
const int * foo = null;

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Nov 10 2009
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=3493


Don <clugdbug yahoo.com.au> changed:

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


--- Comment #1 from Don <clugdbug yahoo.com.au> 2009-11-17 23:55:05 PST ---
This doesn't segfault in D2 because in expression.c, VarExp::semantic(),
line 4152, the initializer part is commented out.

    VarDeclaration *v = var->isVarDeclaration();
    if (v)
    {
+#if 0
    if ((v->isConst() || v->isInvariant()) &&
        type->toBasetype()->ty != Tsarray && v->init)
    {
        ExpInitializer *ei = v->init->isExpInitializer();
        if (ei)
        {
        //ei->exp->implicitCastTo(sc, type)->print();
        return ei->exp->implicitCastTo(sc, type);
        }
    }
+#endif
    v->checkNestedReference(sc, loc);
#if DMDV2

Doing the same thing in D1 fixes this bug, and the DMD test suite still passes.
However I'm not sure why the code above is unnecessary.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Nov 17 2009
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=3493



--- Comment #2 from Don <clugdbug yahoo.com.au> 2010-08-09 02:37:30 PDT ---
Here's a more minimal patch. It shouldn't be implicitly casting the
initializer, if it hasn't run semantic on it yet.

expression.c, VarExp::semantic(), line 3955.

    if (v)
    {
        if (v->isConst() && v->type && type->toBasetype()->ty != Tsarray &&
v->init)
        {
            ExpInitializer *ei = v->init->isExpInitializer();
-            if (ei)
+            if (ei && ei->exp->type)
            {
+                assert(ei->exp->type);
                //ei->exp->implicitCastTo(sc, type)->print();
                return ei->exp->implicitCastTo(sc, type);
            }

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Aug 09 2010
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=3493


Walter Bright <bugzilla digitalmars.com> changed:

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


--- Comment #3 from Walter Bright <bugzilla digitalmars.com> 2010-08-27
22:11:46 PDT ---
http://www.dsource.org/projects/dmd/changeset/637

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Aug 27 2010
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=3493


Walter Bright <bugzilla digitalmars.com> changed:

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


--- Comment #4 from Walter Bright <bugzilla digitalmars.com> 2010-08-30
13:26:04 PDT ---
Undoing the patch for 190 also breaks this.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Aug 30 2010
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=3493


Don <clugdbug yahoo.com.au> changed:

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


--- Comment #5 from Don <clugdbug yahoo.com.au> 2010-11-15 00:16:29 PST ---
Fixed dmd 1.064.

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