[Issue 1021] New: CTFE and functions returning void
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Sun Mar 4 04:40:27 PST 2007
http://d.puremagic.com/issues/show_bug.cgi?id=1021
Summary: CTFE and functions returning void
Product: D
Version: 1.007
Platform: PC
OS/Version: Linux
Status: NEW
Keywords: rejects-valid
Severity: normal
Priority: P2
Component: DMD
AssignedTo: bugzilla at digitalmars.com
ReportedBy: fvbommel at wxs.nl
Functions returning void can't be executed at compile time, even if they have
out/inout parameters:
---
urxae at 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 at 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 at 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 at urxae:~/tmp$ dmd test.d
gcc test.o -o test -m32 -lphobos -lpthread -lm -Xlinker
-L/home/urxae/opt/dmd/lib
---
--
More information about the Digitalmars-d-bugs
mailing list