Bug 8982 – ICE(ctfeexpr.c) __parameters of an erroneous default parameter

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2012-11-08T13:28:00Z
Last change time
2013-01-09T16:43:05Z
Keywords
CTFE, ice, pull
Assigned to
nobody
Creator
bugzilla

Comments

Comment #0 by bugzilla — 2012-11-08T13:28:20Z
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'
Comment #1 by clugdbug — 2012-11-12T00:58:43Z
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?
Comment #2 by clugdbug — 2012-11-12T02:46:28Z
Further reduced: ---- void bug8982(ref const int v = 7 ){} static if (is(typeof(bug8982) P == __parameters)) { pragma(msg, ((P[0..1] g) => g[0])()); }
Comment #3 by clugdbug — 2013-01-09T09:16:52Z
Comment #4 by github-bugzilla — 2013-01-09T16:27:15Z
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).