digitalmars.D.bugs - [Issue 4027] New: Nested function's bug in CTFE
- d-bugmail puremagic.com (47/47) Mar 29 2010 http://d.puremagic.com/issues/show_bug.cgi?id=4027
- d-bugmail puremagic.com (29/29) Mar 30 2010 http://d.puremagic.com/issues/show_bug.cgi?id=4027
- d-bugmail puremagic.com (10/10) Apr 01 2010 http://d.puremagic.com/issues/show_bug.cgi?id=4027
- d-bugmail puremagic.com (11/11) Apr 09 2010 http://d.puremagic.com/issues/show_bug.cgi?id=4027
http://d.puremagic.com/issues/show_bug.cgi?id=4027
Summary: Nested function's bug in CTFE
Product: D
Version: 2.041
Platform: x86
URL: http://dusers.dip.jp/modules/forum/index.php?topic_id=
59#post_id222
OS/Version: Windows
Status: NEW
Severity: normal
Priority: P2
Component: DMD
AssignedTo: nobody puremagic.com
ReportedBy: zan77137 nifty.com
(This bug was posted to the Japanese community site. I translate this report.)
This code doesn't work!
-------------------------------------------
auto f(string s)
{
return { return s; };
}
void main()
{
static immutable s = f("aaa")();
static assert(s == "aaa");// Error: static assert (null == "aaa") is false
}
-------------------------------------------
The function fails regardless of the argument when execute the following codes
in CTFE:
-------------------------------------------
auto f(string s)
{
return { assert(s); };
}
-------------------------------------------
You can take the following measures to avoid this problem:
-------------------------------------------
auto f(string s)
{
auto _s = s;
return { assert(_s); };
}
-------------------------------------------
--
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Mar 29 2010
http://d.puremagic.com/issues/show_bug.cgi?id=4027
Don <clugdbug yahoo.com.au> changed:
What |Removed |Added
----------------------------------------------------------------------------
Keywords| |wrong-code
CC| |clugdbug yahoo.com.au
Summary|Nested function's bug in |Closures in CTFE generate
|CTFE |wrong code
The workaround does NOT work. It only looks as though it does. See this, for
example:
===
string delegate() bug4027(string s1) {
string s = s1;
return { return s; };
}
int food() {
auto a = bug4027("aaa");
auto b = bug4027("bbb");
assert(a() == "aaa"); // fails -- a() is "bbb" !!!
return 1;
}
static assert(food()==1);
----
The root cause is that closures are not yet supported in CTFE. They should
generate an error message at compile time.
--
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Mar 30 2010
http://d.puremagic.com/issues/show_bug.cgi?id=4027
Walter Bright <bugzilla digitalmars.com> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |bugzilla digitalmars.com
13:54:35 PDT ---
changeset 429
--
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Apr 01 2010
http://d.puremagic.com/issues/show_bug.cgi?id=4027
Don <clugdbug yahoo.com.au> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
Resolution| |FIXED
Fixed DMD2.043.
--
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Apr 09 2010









d-bugmail puremagic.com 