Bug 1021 – CTFE and functions returning void

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D1 (retired)
Platform
x86
OS
Linux
Creation time
2007-03-04T06:40:00Z
Last change time
2014-02-16T15:22:46Z
Keywords
rejects-valid
Assigned to
bugzilla
Creator
fvbommel

Comments

Comment #0 by fvbommel — 2007-03-04T06:40:18Z
Functions returning void can't be executed at compile time, even if they have out/inout parameters: --- urxae@urxae:~/tmp$ cat test.d void bar(out int x) { x = 2; } int foo() { int y; bar(y); return y; } const int z = foo(); void main(){} urxae@urxae:~/tmp$ dmd test.d test.d(3): Error: cannot evaluate bar(y) at compile time test.d(5): Error: cannot evaluate foo() at compile time --- If bar returns an unused int it compiles fine: --- urxae@urxae:~/tmp$ cat test.d int bar(out int x) { x = 2; return 1; } int foo() { int y; bar(y); return y; } const int z = foo(); void main(){} urxae@urxae:~/tmp$ dmd test.d gcc test.o -o test -m32 -lphobos -lpthread -lm -Xlinker -L/home/urxae/opt/dmd/lib ---
Comment #1 by bugzilla — 2007-03-19T17:40:43Z
Fixed DMD 1.009
Comment #2 by thomas-dloop — 2007-03-29T14:30:39Z