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).
Comment #1 by thomas-dloop — 2006-09-20T14:20:49Z
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 [email protected] schrieb am 2006-09-16: > http://d.puremagic.com/issues/show_bug.cgi?id=353 > 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" > ---------- <snip> Added to DStress as http://dstress.kuehne.cn/compile/o/opCat_21_A.d http://dstress.kuehne.cn/compile/o/opCat_21_B.d http://dstress.kuehne.cn/compile/o/opCat_21_C.d http://dstress.kuehne.cn/compile/o/opCat_21_D.d http://dstress.kuehne.cn/compile/o/opCat_21_E.d http://dstress.kuehne.cn/compile/o/opCat_21_F.d http://dstress.kuehne.cn/compile/o/opCat_22_A.d http://dstress.kuehne.cn/compile/o/opCat_22_B.d http://dstress.kuehne.cn/compile/o/opCat_22_C.d http://dstress.kuehne.cn/compile/o/opCat_22_D.d http://dstress.kuehne.cn/compile/o/opCat_22_E.d http://dstress.kuehne.cn/compile/o/opCat_22_F.d Thomas -----BEGIN PGP SIGNATURE----- iD8DBQFFEZK9LK5blCcjpWoRAqrbAKCpL/Tfq5p4DhSk3YnpB84rxf4HPgCff/Ek tLKCoqSG5qsDPbP+WgHxtfU= =FZkD -----END PGP SIGNATURE-----
Comment #2 by bugzilla — 2006-11-25T03:49:10Z
Fixed DMD 0.175