www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 2215] New: Forward reference enum with base type within a struct causes Segmentation Fault in the compiler

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

           Summary: Forward reference enum with base type within a struct
                    causes Segmentation Fault in the compiler
           Product: D
           Version: 2.016
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Keywords: ice-on-valid-code
          Severity: major
          Priority: P2
         Component: DMD
        AssignedTo: bugzilla digitalmars.com
        ReportedBy: schveiguy yahoo.com


This code causes a dmd segmentation fault:

struct S
{
    E e;
}

enum E : int
{
    E1
}

replace int with ubyte, also fails.  I think this should be valid code because
moving e outside the struct or putting it in a class works (no errors, no
segfault).

The workaround is to declare the enum first.


-- 
Jul 10 2008
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=2215


schveiguy yahoo.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |benoit tionex.de




------- Comment #1 from schveiguy yahoo.com  2008-08-19 09:04 -------
*** Bug 2290 has been marked as a duplicate of this bug. ***


-- 
Aug 19 2008
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=2215





------- Comment #2 from clugdbug yahoo.com.au  2009-04-02 14:52 -------
This is segfaulting in mtype.c, line 5156. If the enum is forward referenced,
it doesn't know if it's default-initialised, so defaultval is null -> segfault. 

int TypeEnum::isZeroInit()
{
    return sym->defaultval->isBool(FALSE);
}

Unfortunately, 'loc' is not a parameter to isZeroInit, so I don't know how to
give an error msg with missing line number.
There are actually two other places in TypeEnum where this problems happens:
isunsigned() uses memtype without checking.
hasPointers() uses toBaseType() without checking.

alignsize() probably gives error message without line number.


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


Don <clugdbug yahoo.com.au> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |clugdbug yahoo.com.au
         Resolution|                            |FIXED




--- Comment #3 from Don <clugdbug yahoo.com.au>  2009-05-14 07:27:38 PDT ---
Fixed DMD2.030.

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