Thread overview | |||||||||
---|---|---|---|---|---|---|---|---|---|
|
January 02, 2012 [Issue 7197] New: enum string doesn't work with CTFE | ||||
---|---|---|---|---|
| ||||
http://d.puremagic.com/issues/show_bug.cgi?id=7197 Summary: enum string doesn't work with CTFE Product: D Version: D2 Platform: Other OS/Version: Mac OS X Status: NEW Severity: normal Priority: P2 Component: DMD AssignedTo: nobody@puremagic.com ReportedBy: andrei@metalanguage.com --- Comment #0 from Andrei Alexandrescu <andrei@metalanguage.com> 2012-01-01 17:44:07 PST --- import std.stdio; string toConcatenatedForm(string m, string[] args...) { string result = "q{"; for (;;) { if (!m.length) { return result ~ '}'; } if (m[0] != '$') { result ~= m[0]; m = m[1 .. $]; continue; } if (m[1] >= '1' && m[1] <= '9') { result ~= "} ~ "; result ~= "expand!(q{" ~ args[m[1] - '1'] ~ "}) ~ q{"; m = m[2 .. $]; continue; } } } template expand(string m, args...) { enum string expand = mixin(toConcatenatedForm(m, args)); } unittest { enum string s = expand!("$1", "abc"); writeln(s); writeln(expand!("$1", s)); } void main(){} The code above causes an ICE: Assertion failed: (v->ctfeAdrOnStack >= 0 && v->ctfeAdrOnStack < stackPointer()), function setValue, file interpret.c, line 100. Replacing the first line in the unittest with static immutable string s = expand!("$1", "abc"); makes the code work. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
January 02, 2012 [Issue 7197] enum string doesn't work with CTFE | ||||
---|---|---|---|---|
| ||||
Posted in reply to Andrei Alexandrescu | http://d.puremagic.com/issues/show_bug.cgi?id=7197 bearophile_hugs@eml.cc changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |bearophile_hugs@eml.cc --- Comment #1 from bearophile_hugs@eml.cc 2012-01-01 18:15:19 PST --- Reduced a bit: int foo(int[] x...) { return 0; } template bar(y...) { enum int bar = foo(y); } enum int z = 1; enum int w = bar!(z); void main() {} -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
January 25, 2012 Re: [Issue 7197] enum string doesn't work with CTFE | ||||
---|---|---|---|---|
| ||||
Posted in reply to bearophile_hugs@eml.cc | On Monday, 2 January 2012 at 02:15:21 UTC, bearophile_hugs@eml.cc wrote:
> http://d.puremagic.com/issues/show_bug.cgi?id=7197
>
>
> bearophile_hugs@eml.cc changed:
>
> What |Removed |Added
> ----------------------------------------------------------------------------
> CC| |bearophile_hugs@eml.cc
>
>
> --- Comment #1 from bearophile_hugs@eml.cc 2012-01-01 18:15:19 PST ---
> Reduced a bit:
>
>
> int foo(int[] x...) {
> return 0;
> }
> template bar(y...) {
> enum int bar = foo(y);
> }
> enum int z = 1;
> enum int w = bar!(z);
> void main() {}
Weird, it can be fixed by changing z to a const:
int foo(int[] x...) { return 0; }
template bar(y...) { enum int bar = foo(y); }
const int z = 1;
enum int w = bar!(z);
void main() {}
I'm unable to upgrade to 2.057 because of this bug, it works fine in 2.056.
|
January 25, 2012 [Issue 7197] enum string doesn't work with CTFE | ||||
---|---|---|---|---|
| ||||
Posted in reply to Andrei Alexandrescu | http://d.puremagic.com/issues/show_bug.cgi?id=7197 Geoffrey Brown <erkle64@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |erkle64@gmail.com --- Comment #2 from Geoffrey Brown <erkle64@gmail.com> 2012-01-25 10:00:46 PST --- Weird, it can be fixed by changing z to a const: int foo(int[] x...) { return 0; } template bar(y...) { enum int bar = foo(y); } const int z = 1; enum int w = bar!(z); void main() {} I'm unable to upgrade to 2.057 because of this bug, it works fine in 2.056. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
January 25, 2012 [Issue 7197] enum string doesn't work with CTFE | ||||
---|---|---|---|---|
| ||||
Posted in reply to Andrei Alexandrescu | http://d.puremagic.com/issues/show_bug.cgi?id=7197 timon.gehr@gmx.ch changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |timon.gehr@gmx.ch Severity|normal |regression -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
January 27, 2012 [Issue 7197] enum string doesn't work with CTFE | ||||
---|---|---|---|---|
| ||||
Posted in reply to Andrei Alexandrescu | http://d.puremagic.com/issues/show_bug.cgi?id=7197 --- Comment #3 from github-bugzilla@puremagic.com 2012-01-27 00:51:34 PST --- Commit pushed to master at https://github.com/D-Programming-Language/dmd https://github.com/D-Programming-Language/dmd/commit/6c081a2bf05524c83e87c71819a9240009a8a7e7 7197 enum string doesn't work with CTFE Fixes bug 7197. Oddly, this was actually a bug in the const folding for comma expressions. The code was originally there as a workaround for another problem which has since been fixed. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
January 27, 2012 [Issue 7197] enum string doesn't work with CTFE | ||||
---|---|---|---|---|
| ||||
Posted in reply to Andrei Alexandrescu | http://d.puremagic.com/issues/show_bug.cgi?id=7197 Walter Bright <bugzilla@digitalmars.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED Resolution| |FIXED -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
Copyright © 1999-2021 by the D Language Foundation