www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 4434] New: Assertion failed: (tn->mod & MODimmutable || tn->mod & MODshared), function check, file mtype.c, line 887.

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

           Summary: Assertion failed: (tn->mod & MODimmutable || tn->mod &
                    MODshared), function check, file mtype.c, line 887.
           Product: D
           Version: D2
          Platform: x86
        OS/Version: Mac OS X
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: sean invisibleduck.org



---
Compile the following:

private struct MyStruct {}
alias shared MyStruct* MyShared;

If the parens are added to the second line, the assertion failure goes away.

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




This one seems to be really general. I think it's the cause of very many
compiler bugs. Here's a pile of cases which ICE.

struct MyStruct {}
alias const (MyStruct)* MyGoodConst; //OK
alias const MyStruct* MyConst; //ice

alias shared MyStruct* MyShared; //ice
alias shared MyStruct[] MySharedArray; //ice

alias int MyInt;
alias const MyInt[3] MyConstInt; // ice

It happens with const, shared, or immutable, and with *, [], [3], etc --
anything which is a BasicType2.

Interestingly it doesn't seem to happen with typedef, even though the code in
parse.c is almost identical.

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


Don <clugdbug yahoo.com.au> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         OS/Version|Mac OS X                    |All



This has to be a bug either in the parser, or in the type transitivity check.

I've added this line to check that the type being passed to the
AliasDeclaration is correctly constructed. This test fails for the cases which
work!!
---------
parse.c, 2335. Parser::parseBasicType()

        case TOKconst:
            // const(type)
            nextToken();
            check(TOKlparen);
            t = parseType();
            check(TOKrparen);
            if (t->isShared())
                t = t->makeSharedConst();
            else
                t = t->makeConst();
+            t->check();
            break;
---------

// This test case compiles OK, but it fails the check above.
alias int MyInt;
typedef const (MyInt*) MyConstInt;

It's checking that const(MyInt*) is the same as const(const(MyInt)*) -- but
it's isn't!

So really, the difference between the cases that work, and those which fail, is
simply that the latter are checked. The only cases that pass everything are
ones like:  alias const int* XXX;
So either, makeConst() is wrong, or else AliasDeclaration is calling check()
too early; or the check is wrong. I really don't know which it is.

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


Yao Gómez <yao.gomez gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |yao.gomez gmail.com



I have the latest DMD2 compiler, and this also triggers this assertion:

---
static immutable u64 foo[1] = [0x123456789];
---

Note that the u64 identifier is not defined anywere. If I change it to ulong,
it works (obviously). Maybe it has something to do with ids not defined or
something.

The error messages that I get are:

 test.d(18): Error: identifier 'u64' is not defined
 test.d(18): Error: identifier 'u64' is not defined
 test.d(18): Error: u64 is used as a type
 Assertion failure: 'tn->mod == MODimmutable' on line 879 in file 'mtype.c'
-- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Sep 15 2010
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=4434


Don <clugdbug yahoo.com.au> changed:

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



According to TDPL, const T[] is supposed to mean const(const(T)[]).
But currently, it isn't; it's  const(mutable(T)[])
This happens because mtype.c, TypeNext::makeConst() includes a line which
should be deleted:

    if (ty != Tfunction && ty != Tdelegate &&
-        (next->deco || next->ty == Tfunction) &&
        !next->isImmutable() && !next->isConst())
    {   if (next->isShared())
            t->next = next->sharedConstOf();
        else
            t->next = next->constOf();
    }
which means that it's not making the array contents const.
Same change also needs to be applied to TypeNext::makeShared(),
makeSharedConst(), makeInvariant()
and possibly also to makeWild().

Test cases:
-----
struct Bug4434 {}
alias const Bug4434* IceConst4434;
alias shared Bug4434* IceShared4434;
alias shared Bug4434[] IceSharedArray4434;
alias immutable Bug4434* IceImmutable4434;
alias shared const Bug4434* IceSharedConst4434;

alias int MyInt4434;
alias const MyInt4434[3] IceConstInt4434;

alias immutable string[] Bug4830;
---

This patch also fixes these bugs:

Bug 4366 ICE(mtype.c) constrained template pure function with array/pointer
parameter
Bug 4709 ICE(mtype.c): undefined variable in const struct
Bug 4743 ICE(mtype.c) involving "in UnknownType*"
Bug 4830 Regression(2.038) ICE mtype.c:879: void Type::check(): Assertion
`tn->mod == 4' failed
Bug 4871 ICE(mtype.c 875) const alias
Bug 4964 ICE(mtype.c) casting to undefined types
Bug 4980 ICE(mtype.c) on unknown type in a shared class/struct

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


bearophile_hugs eml.cc changed:

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



8 issues fixed removing one line? :-)

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


Walter Bright <bugzilla digitalmars.com> changed:

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



12:22:23 PST ---
http://www.dsource.org/projects/dmd/changeset/739

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


Walter Bright <bugzilla digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |rsinfu gmail.com



12:25:27 PST ---
*** Issue 4366 has been marked as a duplicate of this issue. ***

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


Walter Bright <bugzilla digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |bitworld qq.com



12:27:23 PST ---
*** Issue 4709 has been marked as a duplicate of this issue. ***

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


Walter Bright <bugzilla digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |2korden gmail.com



12:28:18 PST ---
*** Issue 4743 has been marked as a duplicate of this issue. ***

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


Walter Bright <bugzilla digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |ellery-newcomer utulsa.edu



12:28:56 PST ---
*** Issue 4830 has been marked as a duplicate of this issue. ***

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


Walter Bright <bugzilla digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |cruxic gmail.com



12:29:29 PST ---
*** Issue 4871 has been marked as a duplicate of this issue. ***

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


Walter Bright <bugzilla digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |spam extrawurst.org



12:30:01 PST ---
*** Issue 4964 has been marked as a duplicate of this issue. ***

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




12:30:30 PST ---
*** Issue 4980 has been marked as a duplicate of this issue. ***

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




*** Issue 5287 has been marked as a duplicate of this issue. ***

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




*** Issue 5303 has been marked as a duplicate of this issue. ***

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