Bug 2089 – Issues with CTFE and tuple indexes

Status
RESOLVED
Resolution
FIXED
Severity
major
Priority
P2
Component
dmd
Product
D
Version
D1 (retired)
Platform
x86
OS
Windows
Creation time
2008-05-09T11:45:00Z
Last change time
2014-02-24T15:33:39Z
Assigned to
bugzilla
Creator
samukha

Comments

Comment #0 by samukha — 2008-05-09T11:45:32Z
---- template Tuple(A...) { alias A Tuple; } alias Tuple!("one", "two") tuple; size_t foo() { return 1; } static assert(tuple[foo()] == "two"); void main() {} ---- Output: test.d(24): Error: Integer constant expression expected instead of foo() Bogus output when the tuple is indexed in msg pragma (introducing an intermediate const does not help): ---- template Tuple(A...) { alias A Tuple; } alias Tuple!("one", "two") tuple; size_t foo() { return 1; } const i = foo(); pragma(msg, tuple[i]); // fails // static assert(tuple[i] == "two"); // while this passes void main() {} ---- Output: test.d(24): Error: Integer constant expression expected instead of foo() one IIRC, a similar bug was posted long time ago. If anybody can find it, please mark it a duplicate.
Comment #1 by bugzilla — 2008-05-22T05:06:19Z
Fixed dmd 1.030 and 2.014