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


--- Comment #0 from Shin Fujishiro <rsinfu gmail.com> 2010-06-22 04:56:04 PDT
---
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:
...
#3  0x283a2ef6 in __assert () from /lib/libc.so.7
#4  0x080fa0fe in Type::check ()
#5  0x080fa23f in Type::fixTo ()
#6  0x081001b7 in Type::constOf ()
#7  0x08136150 in TemplateDeclaration::makeParamNamesVisibleInConstraint ()
#8  0x08136415 in TemplateDeclaration::matchWithInstance ()
#9  0x08138cac in TemplateInstance::findBestMatch ()
#10 0x08139c67 in TemplateInstance::semantic ()
#11 0x0813a190 in TemplateInstance::semantic ()
#12 0x081005d3 in TypeInstance::resolve ()
...


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


--- Comment #1 from Don <clugdbug yahoo.com.au> 2010-06-24 00:29:57 PDT ---
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


--- Comment #2 from Walter Bright <bugzilla digitalmars.com> 2010-11-07
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