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

D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 923 - No constant folding for template value default arguments, D1 only
Summary: No constant folding for template value default arguments, D1 only
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D1 (retired)
Hardware: x86 All
: P2 normal
Assignee: No Owner
URL:
Keywords: patch, rejects-valid
Depends on:
Blocks:
Reported: 2007年02月02日 13:13 UTC by Don
Modified: 2014年02月16日 15:22 UTC (History)
0 users

See Also:


Attachments
Add an attachment (proposed patch, testcase, etc.)

Note You need to log in before you can comment on or make changes to this issue.
Description Don 2007年02月02日 13:13:19 UTC
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 2 Don 2009年08月13日 04:43:06 UTC
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 Don 2009年10月21日 06:40:11 UTC
Fixed DMD1.050.


AltStyle によって変換されたページ (->オリジナル) /