Thread overview
[Issue 2851] New: Segfault using C-style struct initializer with too few arguments
Apr 18, 2009
d-bugmail
May 14, 2009
Don
[Issue 2851] Segfault(expression.c) using C-style struct initializer with too few arguments
May 15, 2009
Walter Bright
May 15, 2009
Gide Nwawudu
Aug 13, 2009
Don
Oct 13, 2009
Walter Bright
April 18, 2009
http://d.puremagic.com/issues/show_bug.cgi?id=2851

           Summary: Segfault using C-style struct initializer with too few
                    arguments
           Product: D
           Version: 2.027
          Platform: PC
        OS/Version: Windows
            Status: NEW
          Keywords: accepts-invalid, ice-on-invalid-code
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: bugzilla@digitalmars.com
        ReportedBy: clugdbug@yahoo.com.au


The bug is that it doesn't check that the number of members in the initializer is correct. It's silently accepted as long as you don't access an uninitialised member; if you do, the compiler segfaults.

----
struct Test{
 int foo;
}

enum Test test = {};
enum q = test.foo;


-- 

May 14, 2009
http://d.puremagic.com/issues/show_bug.cgi?id=2851





--- Comment #1 from Don <clugdbug@yahoo.com.au>  2009-05-14 01:34:55 PDT ---
Fixed in DMD2.030, NOT FIXED in DMD1.045.

struct Test{
 int foo;
}

const Test test = {};
const q = test.foo;

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
May 15, 2009
http://d.puremagic.com/issues/show_bug.cgi?id=2851


Walter Bright <bugzilla@digitalmars.com> changed:

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




--- Comment #2 from Walter Bright <bugzilla@digitalmars.com>  2009-05-15 12:19:00 PDT ---
Fixed dmd 2.030

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
May 15, 2009
http://d.puremagic.com/issues/show_bug.cgi?id=2851


Gide Nwawudu <gide@nwawudu.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|RESOLVED                    |REOPENED
                 CC|                            |gide@nwawudu.com
         Resolution|FIXED                       |




--- Comment #3 from Gide Nwawudu <gide@nwawudu.com>  2009-05-15 16:13:17 PDT ---
Re-opened because DMD 1.045 segfaults.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
August 13, 2009
http://d.puremagic.com/issues/show_bug.cgi?id=2851


Don <clugdbug@yahoo.com.au> changed:

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




--- Comment #4 from Don <clugdbug@yahoo.com.au>  2009-08-13 00:00:52 PDT ---
Seems like this was just missed in copying from D2 to D1. Segfaulting in StructLiteralExp::getFieldIndex() in expression.c.

PATCH:
Just copy int StructLiteralExp::getFieldIndex(Type *type, unsigned offset)
(line 3197) from D2 to D1. (Needs if(elements->dim){ ... } around the for
loop).

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
October 13, 2009
http://d.puremagic.com/issues/show_bug.cgi?id=2851


Walter Bright <bugzilla@digitalmars.com> changed:

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


--- Comment #5 from Walter Bright <bugzilla@digitalmars.com> 2009-10-13 13:51:30 PDT ---
Fixed dmd 1.049

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