www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 2827] New: Crash compiling a foreach on an invalid class

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

           Summary: Crash compiling a foreach on an invalid class
           Product: D
           Version: 2.027
          Platform: PC
        OS/Version: Windows
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: bugzilla digitalmars.com
        ReportedBy: unknown simplemachines.org


When compiling the following code, DMD crashes (after issuing appropriate
errors):

---
import std.stdio;

void main()
{
        BadClass file;

        foreach (char[] line; file)
                writefln(line);
}
---

Not a huge issue, found when forgetting to import std.stream.  Patch upcoming.

-[Unknown]


-- 
Apr 09 2009
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=2827





------- Comment #1 from unknown simplemachines.org  2009-04-10 00:59 -------
Created an attachment (id=320)
 --> (http://d.puremagic.com/issues/attachment.cgi?id=320&action=view)
Call semantic even when foreaching over invalid data.

This patch makes it still call semantic() on body, even if foreaching over an
int or some such.

This might cause additional noise ("undefined identifier line" here), but it
makes it not crash and seems like the logical thing to do, according to usual
convention when handling errors.

DMD 1.x doesn't crash in this instance, because there's no nothrow involved.  I
would expect this patch would help DMD 1 too.

-[Unknown]


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


bugzilla digitalmars.com changed:

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




------- Comment #2 from bugzilla digitalmars.com  2009-05-02 10:05 -------
works dmd 2.029


-- 
May 02 2009