Bug 923 – No constant folding for template value default arguments, D1 only

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D1 (retired)
Platform
x86
OS
All
Creation time
2007-02-02T13:13:00Z
Last change time
2014-02-16T15:22:03Z
Keywords
patch, rejects-valid
Assigned to
nobody
Creator
clugdbug

Comments

Comment #0 by clugdbug — 2007-02-02T13:13:19Z
Error: expression 1 + 2 is not a valid template value argument ---------- void a(int b = 1+2)(){}; void main() { a!(1+2)(); // OK a(); // fails }
Comment #1 by thomas-dloop — 2007-04-05T11:38:52Z
Comment #2 by clugdbug — 2009-08-13T04:43:06Z
This has already been fixed in D2. Here's the patch for D1.046. It's trivial. Index: template.c =================================================================== --- template.c (revision 192) +++ template.c (working copy) @@ -3951,6 +3951,7 @@ { sinteger_t v; real_t r; + ea = ea->optimize(WANTvalue | WANTinterpret); if (ea->op == TOKvar) { sa = ((VarExp *)ea)->var;
Comment #3 by clugdbug — 2009-10-21T06:40:11Z
Fixed DMD1.050.