Bug 353 – null passed as a char[] template argument, concatenated with a string literal, is a non-constant expression
Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D1 (retired)
Platform
x86
OS
Windows
Creation time
2006-09-16T18:20:00Z
Last change time
2014-02-15T13:18:57Z
Keywords
rejects-valid
Assigned to
bugzilla
Creator
smjg
Comments
Comment #0 by smjg — 2006-09-16T18:20:16Z
----------
template Qwert(char[] yuiop) {
const char[] Qwert = yuiop ~ "asdfg";
}
void main() {
char[] hjkl = Qwert!(null);
}
----------
D:\My Documents\Programming\D\Tests\bugs\string_template7.d(2): non-constant expression null ~ "asdfg"
----------
No such error occurs if null is replaced by a string literal, or if line 2 is changed to
const char[] Qwert = yuiop;
If, starting with the original code, hjkl is declared at module level, the error is doubled:
----------
template Qwert(char[] yuiop) {
const char[] Qwert = yuiop ~ "asdfg";
}
char[] hjkl = Qwert!(null);
----------
D:\My Documents\Programming\D\Tests\bugs\string_template7a.d(5): non-constant expression null ~ "asdfg"
D:\My Documents\Programming\D\Tests\bugs\string_template7a.d(2): non-constant expression null ~ "asdfg"
----------
If hjkl is declared as const and at module level, then the error is tripled (at lines 5, 2 and 2).