digitalmars.D.bugs - [Issue 5671] New: CTFE string concat problem
- d-bugmail puremagic.com (38/38) Mar 01 2011 http://d.puremagic.com/issues/show_bug.cgi?id=5671
- d-bugmail puremagic.com (18/18) Mar 01 2011 http://d.puremagic.com/issues/show_bug.cgi?id=5671
- d-bugmail puremagic.com (7/7) Mar 05 2011 http://d.puremagic.com/issues/show_bug.cgi?id=5671
- d-bugmail puremagic.com (13/13) Apr 18 2011 http://d.puremagic.com/issues/show_bug.cgi?id=5671
http://d.puremagic.com/issues/show_bug.cgi?id=5671
Summary: CTFE string concat problem
Product: D
Version: D2
Platform: x86
OS/Version: Windows
Status: NEW
Keywords: rejects-valid
Severity: normal
Priority: P2
Component: DMD
AssignedTo: nobody puremagic.com
ReportedBy: bearophile_hugs eml.cc
A problem found by Peter Lundgren and David Nadlinger.
Reduced D2 code:
import std.conv: to;
string foo() {
// return to!string(10); // OK
return to!string(10) ~ "";
}
string s = foo();
void main() {}
DMD 2.052 gives the errors:
test.d(4): Error: to(10) ~ "" cannot be interpreted at compile time
test.d(6): Error: cannot evaluate foo() at compile time
test.d(6): Error: cannot evaluate foo() at compile time
I think it's not a problem of to!() because this alternative version works
correctly:
import std.conv: to;
string foo() {
return to!string(10);
}
string s = foo();
void main() {}
--
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Mar 01 2011
http://d.puremagic.com/issues/show_bug.cgi?id=5671
Don <clugdbug yahoo.com.au> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |clugdbug yahoo.com.au
Reduced test case shows it is a constant folding problem.
['a', 'b'] ~ "c" doesn't get constant folded.
string foo5671() {
return ['a', 'b'];
}
string bug5671() {
return foo5671() ~ "c";
}
static assert(bug5671() == "abc");
--
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Mar 01 2011
http://d.puremagic.com/issues/show_bug.cgi?id=5671 Can be reduced even further, showing CTFE isn't involved at all: static assert( ['a', 'b'] ~ "c" == "abc" ); -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Mar 05 2011
http://d.puremagic.com/issues/show_bug.cgi?id=5671
Walter Bright <bugzilla digitalmars.com> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
CC| |bugzilla digitalmars.com
Resolution| |FIXED
16:02:31 PDT ---
https://github.com/D-Programming-Language/dmd/commit/316ba0a77e3934bfc8091940444f706e82aecc72
https://github.com/D-Programming-Language/dmd/commit/5c7c6b51e27d9cd394ddda4f7940cdf9c1610953
--
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Apr 18 2011









d-bugmail puremagic.com 