Thread overview
[Issue 8982] New: Assertion failure: '0' on line 353 in file 'ctfeexpr.c'
Nov 08, 2012
Walter Bright
Nov 12, 2012
Don
Nov 12, 2012
Don
[Issue 8982] ICE(ctfeexpr.c) __parameters of an erroneous default parameter
Jan 09, 2013
Don
Jan 10, 2013
Kenji Hara
November 08, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=8982

           Summary: Assertion failure: '0' on line 353 in file
                    'ctfeexpr.c'
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody@puremagic.com
        ReportedBy: bugzilla@digitalmars.com


--- Comment #0 from Walter Bright <bugzilla@digitalmars.com> 2012-11-08 13:28:20 PST ---
The following:
----------------------
import std.traits;

struct Vector
{
 float x,y,z,w;
 immutable Vector one = Vector(1,1,1,1);
}

void func(int x = 10, ref const Vector v = Vector(1,1,1,1));

pragma(msg, ParameterDefaultValueTuple!func);
-------------------------

produces:

bar.d(10): Error: Vector(1F,1F,1F,1F) is not an lvalue
Assertion failure: '0' on line 353 in file 'ctfeexpr.c'

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
November 12, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=8982



--- Comment #1 from Don <clugdbug@yahoo.com.au> 2012-11-12 00:58:43 PST ---
Somewhat reduced test case:

template Bug8982(func...)
{
    static if (is(typeof(func[0]) PT == __parameters))
    {
        enum Bug8982 = ((PT[0..1] args) => args[0])();
    }
}

struct V8982 {
    float x;
}

int func(ref const V8982 v = V8982(1) ){
    return 1;
}

pragma(msg, Bug8982!func);
----
The error occurs while evaluating the default argument. The resulting ErrorExp should not be passed to CTFE, though the question is, at which stage should it it be rejected? When instantiating the template? At is(__parameters)? Or when creating the delegate?

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
November 12, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=8982



--- Comment #2 from Don <clugdbug@yahoo.com.au> 2012-11-12 02:46:28 PST ---
Further reduced:
----
void bug8982(ref const int v = 7 ){}

static if (is(typeof(bug8982) P == __parameters)) {
    pragma(msg, ((P[0..1] g) => g[0])());
}

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
January 09, 2013
http://d.puremagic.com/issues/show_bug.cgi?id=8982



--- Comment #3 from Don <clugdbug@yahoo.com.au> 2013-01-09 09:16:52 PST ---
https://github.com/D-Programming-Language/dmd/pull/1453

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
January 10, 2013
http://d.puremagic.com/issues/show_bug.cgi?id=8982



--- Comment #4 from github-bugzilla@puremagic.com 2013-01-09 16:27:15 PST ---
Commit pushed to master at https://github.com/D-Programming-Language/dmd

https://github.com/D-Programming-Language/dmd/commit/d71cf042b7ff685699f0a312760dfead6af70cb4 Fix issue 8982 ICE(ctfeexpr.c) __parameters of an erroneous default parameter

Don't create a tuple with an error in it; instead, return an ErrorExp.
This is the same behaviour you get when creating a erroneous tuple by normal
means.

(The test case is wrapped in a speculative template so that the module compiles
even though
it contains an error).

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
January 10, 2013
http://d.puremagic.com/issues/show_bug.cgi?id=8982


Kenji Hara <k.hara.pg@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED


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