[Issue 6164] New: [CTFE] Local arrays in a recursive local function behave funny
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Thu Jun 16 12:45:31 PDT 2011
http://d.puremagic.com/issues/show_bug.cgi?id=6164
Summary: [CTFE] Local arrays in a recursive local function
behave funny
Product: D
Version: D2
Platform: All
OS/Version: All
Status: NEW
Severity: normal
Priority: P2
Component: DMD
AssignedTo: nobody at puremagic.com
ReportedBy: timon.gehr at gmx.ch
--- Comment #0 from timon.gehr at gmx.ch 2011-06-16 12:40:49 PDT ---
This is tt.d:
import std.stdio;
string ctfe(){
int[] ctfe2(int n){
int[] r=[];
if(n!=0) r~=[1]~ctfe2(n-1);
return r;
}
return ctfe2(2).length == 2 ?
"hello from runtime!" : "hello from compile time!";
}
void main(){
pragma(msg,ctfe());
writeln(ctfe());
}
$ dmd -run tt;
hello from compile time!
hello from runtime!
$
The ctfe'd result is generally longer than the correct one.
The example works as expected if ctfe2 is moved outside ctfe.
--
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
More information about the Digitalmars-d-bugs
mailing list