www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 6599] New: Bus error with non-constant expression and struct initializer

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

           Summary: Bus error with non-constant expression and struct
                    initializer
           Product: D
           Version: D1 & D2
          Platform: Other
        OS/Version: Mac OS X
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: doob me.com



Compiling the following code results in a bus error:

class Orbit
{
    Repository repository = Repository();
}

struct Repository
{
    string fileProtocol = "file://";
    string source = fileProtocol ~ "/usr/local/orbit/repository";
}

void main () {}

DMD 1.069 and 2.054
Mac OS X 10.6.8

GDB session:

(gdb) r 
Starting program: /Users/doob/.dvm/compilers/dmd-1.069/bin/dmd test.d

Program received signal EXC_BAD_ACCESS, Could not access memory.
Reason: KERN_PROTECTION_FAILURE at address: 0x00000000
0x000529b0 in InterfaceDeclaration::~InterfaceDeclaration ()
(gdb) bt











(gdb)

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Sep 03 2011
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=6599


yebblies <yebblies gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |ice-on-invalid-code
                 CC|                            |yebblies gmail.com
           Platform|Other                       |All
            Summary|Bus error with non-constant |ICE(constfold.c) On use of
                   |expression and struct       |invalid expression as a
                   |initializer                 |compile-time initializer
         OS/Version|Mac OS X                    |All



That's a strange place to get the error.  I get an AV at constfold.c:1396.

CatExp::optimize calls :optimize on fileProtocol (which does nothing) then
passes it along to Cat, which crashes trying to access fileProtocol's type.

It seems to happen for all operators:

class Orbit
{
    Repository repository = Repository();
}

struct Repository
{
    //int source = xx ~ xx;
    //int source = xx + xx;
    //int source = xx - xx;
    //int source = xx * xx;
    //int source = xx / xx;
    //int source = xx ^^ xx;
    //int source = xx & xx;
    int source = xx | xx;
}

void main () {}

It is probably invalid to assume e->type has been set inside Cat and other
constfold functions.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Sep 05 2011
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=6599


Don <clugdbug yahoo.com.au> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |clugdbug yahoo.com.au




 That's a strange place to get the error.  I get an AV at constfold.c:1396.
 
 CatExp::optimize calls :optimize on fileProtocol (which does nothing) then
 passes it along to Cat, which crashes trying to access fileProtocol's type.
 
 It seems to happen for all operators:
[snip]
 It is probably invalid to assume e->type has been set inside Cat and other
 constfold functions.
No, it's valid. Those functions should only be called after the semantic pass was completed successfully on the expression. This is yet another gagging system bug. Repository is forward referenced from Orbit. Semantic is run on Repository with errors gagged. This semantic pass fails, but leaves Repository's members in an invalid state. If you move Orbit after Repository, you see the correct error messages. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Sep 07 2011
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=6599






 That's a strange place to get the error.  I get an AV at constfold.c:1396.
 
 CatExp::optimize calls :optimize on fileProtocol (which does nothing) then
 passes it along to Cat, which crashes trying to access fileProtocol's type.
 
 It seems to happen for all operators:
[snip]
 It is probably invalid to assume e->type has been set inside Cat and other
 constfold functions.
No, it's valid. Those functions should only be called after the semantic pass was completed successfully on the expression. This is yet another gagging system bug. Repository is forward referenced from Orbit. Semantic is run on Repository with errors gagged. This semantic pass fails, but leaves Repository's members in an invalid state. If you move Orbit after Repository, you see the correct error messages.
Ok. That would make this another case of bug 4269? -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Sep 07 2011
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=6599




With DMD 1.069 I get the same error even when I place Repository before Orbit.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Sep 07 2011
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=6599






 This is yet another gagging system bug.
 
 Repository is forward referenced from Orbit. Semantic is run on Repository with
 errors gagged. This semantic pass fails, but leaves Repository's members in an
 invalid state.
 If you move Orbit after Repository, you see the correct error messages.
Ok. That would make this another case of bug 4269?
They have the same kind of structural cause in the compiler, but I think they don't have any of the same code in common. It's definitely not a duplicate. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Sep 07 2011
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=6599


Walter Bright <bugzilla digitalmars.com> changed:

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



13:16:58 PDT ---
https://github.com/D-Programming-Language/dmd/commit/6dc84fd7f2f43d28039d08bf80658cffc97e00f0

https://github.com/D-Programming-Language/dmd/commit/cf7a78423f426fb0d2d62b0af821129f1a4077a1

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