Thread overview
[Issue 1021] New: CTFE and functions returning void
Mar 04, 2007
d-bugmail
Mar 19, 2007
d-bugmail
Mar 29, 2007
d-bugmail
March 04, 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@digitalmars.com
        ReportedBy: fvbommel@wxs.nl


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
---


-- 

March 19, 2007
http://d.puremagic.com/issues/show_bug.cgi?id=1021


bugzilla@digitalmars.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED




------- Comment #1 from bugzilla@digitalmars.com  2007-03-19 17:40 -------
Fixed DMD 1.009


-- 

March 29, 2007
http://d.puremagic.com/issues/show_bug.cgi?id=1021





------- Comment #2 from thomas-dloop@kuehne.cn  2007-03-29 14:30 -------
Added to DStress as http://dstress.kuehne.cn/compile/i/inerpret_05_A.d http://dstress.kuehne.cn/compile/i/inerpret_05_B.d


--