www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 2577] New: DMD crashes on foreach of undefined identifier

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

           Summary: DMD crashes on foreach of undefined identifier
           Product: D
           Version: 2.023
          Platform: PC
        OS/Version: Windows
            Status: NEW
          Keywords: ice-on-invalid-code
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: bugzilla digitalmars.com
        ReportedBy: smjg iname.com


----------
void main() {
    foreach (element; undef) {
        fn(element);
    }
}

void fn(int i) {}
----------
C:\Users\Stewart\Documents\Programming\D\Tests\bugs>dmd foreach_undef.d
foreach_undef.d(2): Error: undefined identifier undef
foreach_undef.d(2): Error: foreach: int is not an aggregate type
----------
followed by a Windows application failure dialog, showing the details:
----------
Problem signature:
  Problem Event Name:   APPCRASH
  Application Name:     dmd.exe
  Application Version:  0.0.0.0
  Application Timestamp:        00000000
  Fault Module Name:    dmd.exe
  Fault Module Version: 0.0.0.0
  Fault Module Timestamp:       00000000
  Exception Code:       c0000005
  Exception Offset:     0001ccec
  OS Version:   6.0.6001.2.1.0.768.3
  Locale ID:    2057
  Additional Information 1:     64bb
  Additional Information 2:     a42ac0f0b295811241a2caffb74a0ff1
  Additional Information 3:     b17c
  Additional Information 4:     af2368a443111b924ca617c6f294878c

Read our privacy statement:
  http://go.microsoft.com/fwlink/?linkid=50163&clcid=0x0409
----------

Specifying the type of element makes no difference.  If element is unused
inside the for loop, the crash disappears.


-- 
Jan 10 2009
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=2577


matti.niemenmaa+dbugzilla iki.fi changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |samukha voliacable.com




------- Comment #1 from matti.niemenmaa+dbugzilla iki.fi  2009-01-13 10:16
-------
*** Bug 2583 has been marked as a duplicate of this bug. ***


-- 
Jan 13 2009
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=2577


smjg iname.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |georg iki.fi




------- Comment #2 from smjg iname.com  2009-03-05 19:55 -------
*** Bug 2709 has been marked as a duplicate of this bug. ***


-- 
Mar 05 2009
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=2577


clugdbug yahoo.com.au changed:

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




------- Comment #3 from clugdbug yahoo.com.au  2009-04-02 15:42 -------

in expression.c, in CallExp::canThrow(), around line 6660, type will be null if
the expression was invalid. Adding a null check fixes the segfault.

    /* If calling a function or delegate that is typed as nothrow,
     * then this expression cannot throw.
     * Note that pure functions can throw.
     */
        if (!e1->type) return 0;  // ---- add this line

    Type *t = e1->type->toBasetype();
    if (t->ty == Tfunction && ((TypeFunction *)t)->isnothrow)
        return 0;


-- 
Apr 02 2009
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=2577


clugdbug yahoo.com.au changed:

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




------- Comment #4 from clugdbug yahoo.com.au  2009-04-18 01:07 -------
Fixed DMD2.028


-- 
Apr 17 2009