www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 4709] New: const struct leads DMD terminated abnormally

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

           Summary: const struct leads DMD terminated abnormally
           Product: D
           Version: D2
          Platform: x86
        OS/Version: Windows
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: bitworld qq.com



The following code will lead DMD terminated abnormally. After getting rid of
the "const" in "const struct SB_uint8", this termination problem is missing. 
===================
import std.stdio;

/*
struct D_Shift {
  ushort    symbol;
  ubyte        shift_kind;
  ubyte        op_assoc;
  int        op_priority;
  int        term_priority;
  int        action_index;
}
*/

// the bug is here
const struct SB_uint8 {
  D_Shift         **shift;
  ubyte    *[2] scanner_block;
}

int main(string[] args)
{
    return 0;
}

/*
Z:\>dmd main.d
main.d(17): Error: identifier 'D_Shift' is not defined
main.d(17): Error: D_Shift is used as a type
main.d(20): Error: identifier 'D_Shift' is not defined
main.d(20): Error: D_Shift is used as a type
Assertion failure: 'tn->mod & MODimmutable || tn->mod & MODconst' on line 875
in
 file 'mtype.c'

abnormal program termination
*/

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Aug 22 2010
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=4709


bearophile_hugs eml.cc changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |bearophile_hugs eml.cc



It's the undefined Bar inside a const struct that causes the problem:


const struct Foo {
    Bar* p;
}
void main() {}

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Aug 22 2010
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=4709


Jeremy <jerminatorster+dbugs gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jerminatorster+dbugs gmail.
                   |                            |com



PDT ---
I get this same bug using 'alias const', eg:

alias int ITEMIDLIST_ABSOLUTE;
alias const ITEMIDLIST_ABSOLUTE *PCIDLIST_ABSOLUTE;

Gives the same compile error:
Assertion failure: 'tn->mod & MODimmutable || tn->mod & MODconst' on line 875
in file 'mtype.c'

This also happens if you use a struct:

struct ITEMIDLIST_ABSOLUTE
{
    int foo;
}
alias const ITEMIDLIST_ABSOLUTE *PCIDLIST_ABSOLUTE;

But *not* if you use a primitive type directly:

alias const int *PCIDLIST_ABSOLUTE;

Removing the const also avoids the error.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Nov 06 2010
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=4709


Don <clugdbug yahoo.com.au> changed:

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



My patch for bug 4434 fixes this.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Nov 06 2010
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=4709


Walter Bright <bugzilla digitalmars.com> changed:

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



12:27:23 PST ---
*** This issue has been marked as a duplicate of issue 4434 ***

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