www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 4366] New: ICE(mtype.c) constrained template pure function with array/pointer parameter

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

           Summary: ICE(mtype.c) constrained template pure function with
                    array/pointer parameter
           Product: D
           Version: 2.041
          Platform: All
        OS/Version: All
            Status: NEW
          Keywords: ice-on-valid-code
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: rsinfu gmail.com



---
DMD aborts with assertion failure in Type::check() if a constrained templated
pure function has a named parameter of array or pointer type.

Compiling the following causes dmd to abort (2.045 and r556):
--------------------
void foo(T)(T a, T[] b) pure if (1)
{
}
alias foo!(int) K;
--------------------
% dmd -o- -c test
Assertion failed: (tn->mod & MODimmutable || tn->mod & MODconst), function
check, file mtype.c, line 871.
--------------------

GDB backtrace:
...










...


The assertion does not fail in the following cases:
--------------------
void bar(T)(T a, T[] b) pure        { } // no constraint
void dee(T)(T a, T[]  ) pure if (1) { } // array parameter is unnamed
void mew(T)(T a, T[] b)      if (1) { } // impure

alias bar!(int) L; // okay
alias dee!(int) M; // okay
alias mew!(int) N; // okay
--------------------

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


Don <clugdbug yahoo.com.au> changed:

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



The ICE occurs during the call in these lines in template.c,
makeParamNamesVisibleInConstraint().

           if (fd->type && fd->isPure())
                vtype = vtype->addMod(MODconst);

Removing those lines allows the code to compile, and the DMD test suite still
passes. So why are they there? I wrote the makeParamNamesVisibleInConstraint()
function, but I just copied those lines from func.c, where interestingly they
don't cause any problems. Still need to work out what the difference is.

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


Walter Bright <bugzilla digitalmars.com> changed:

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



12:25:27 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