1021 – CTFE and functions returning void

D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 1021 - CTFE and functions returning void
Summary: CTFE and functions returning void
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D1 (retired)
Hardware: x86 Linux
: P2 normal
Assignee: Walter Bright
URL:
Keywords: rejects-valid
Depends on:
Blocks:
Reported: 2007年03月04日 06:40 UTC by Frits van Bommel
Modified: 2014年02月16日 15:22 UTC (History)
0 users

See Also:


Attachments
Add an attachment (proposed patch, testcase, etc.)

Note You need to log in before you can comment on or make changes to this issue.
Description Frits van Bommel 2007年03月04日 06:40:18 UTC
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 Walter Bright 2007年03月19日 17:40:43 UTC
Fixed DMD 1.009


AltStyle によって変換されたページ (->オリジナル) /