Jump to page: 1 2
Thread overview
[Issue 4434] New: Assertion failed: (tn->mod & MODimmutable || tn->mod & MODshared), function check, file mtype.c, line 887.
Jul 06, 2010
Sean Kelly
Aug 10, 2010
Don
Aug 11, 2010
Don
Sep 16, 2010
Yao Gómez
[Issue 4434] ICE(mtype.c, 887) alias with const, shared, or immutable
Nov 03, 2010
Don
Nov 07, 2010
Walter Bright
Nov 07, 2010
Walter Bright
Nov 07, 2010
Walter Bright
Nov 07, 2010
Walter Bright
Nov 07, 2010
Walter Bright
Nov 07, 2010
Walter Bright
Nov 07, 2010
Walter Bright
Nov 07, 2010
Walter Bright
Nov 29, 2010
Don
Dec 02, 2010
Don
July 06, 2010
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


--- Comment #0 from Sean Kelly <sean@invisibleduck.org> 2010-07-06 15:35:16 PDT ---
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: -------
August 10, 2010
http://d.puremagic.com/issues/show_bug.cgi?id=4434



--- Comment #1 from Don <clugdbug@yahoo.com.au> 2010-08-10 13:10:44 PDT ---
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: -------
August 11, 2010
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


--- Comment #2 from Don <clugdbug@yahoo.com.au> 2010-08-11 00:51:57 PDT ---
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: -------
September 16, 2010
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


--- Comment #3 from Yao Gómez <yao.gomez@gmail.com> 2010-09-15 21:40:02 PDT ---
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: -------
November 03, 2010
http://d.puremagic.com/issues/show_bug.cgi?id=4434


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

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


--- Comment #4 from Don <clugdbug@yahoo.com.au> 2010-11-03 05:21:34 PDT ---
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: -------
November 03, 2010
http://d.puremagic.com/issues/show_bug.cgi?id=4434


bearophile_hugs@eml.cc changed:

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


--- Comment #5 from bearophile_hugs@eml.cc 2010-11-03 05:48:34 PDT ---
8 issues fixed removing one line? :-)

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
November 07, 2010
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


--- Comment #6 from Walter Bright <bugzilla@digitalmars.com> 2010-11-07 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: -------
November 07, 2010
http://d.puremagic.com/issues/show_bug.cgi?id=4434


Walter Bright <bugzilla@digitalmars.com> changed:

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


--- Comment #7 from Walter Bright <bugzilla@digitalmars.com> 2010-11-07 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: -------
November 07, 2010
http://d.puremagic.com/issues/show_bug.cgi?id=4434


Walter Bright <bugzilla@digitalmars.com> changed:

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


--- Comment #8 from Walter Bright <bugzilla@digitalmars.com> 2010-11-07 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: -------
November 07, 2010
http://d.puremagic.com/issues/show_bug.cgi?id=4434


Walter Bright <bugzilla@digitalmars.com> changed:

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


--- Comment #9 from Walter Bright <bugzilla@digitalmars.com> 2010-11-07 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: -------
« First   ‹ Prev
1 2