Bug 7788 – __gshared and UFCS - "Error: nested structs with constructors are not yet supported in CTFE (Bug 6419)"
Status
RESOLVED
Resolution
INVALID
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
Linux
Creation time
2012-03-28T00:41:00Z
Last change time
2012-04-04T11:58:26Z
Keywords
rejects-valid
Assigned to
nobody
Creator
simendsjo
Comments
Comment #0 by simendsjo — 2012-03-28T00:41:09Z
The following worked on an earlier head of 2.059, but as of yesterday, it fails:
import std.algorithm, std.array, std.utf, std.conv;
void main() {
auto ok = [1].map!("a*1")().array();
__gshared auto ok2 = [1].map!("a*1")();
__gshared auto bug = [1].map!("a*1")().array();
}
Only tested on linux with and without -m32
Comment #1 by simendsjo — 2012-03-28T00:44:40Z
Oh, and the following works too:
__gshared int[] ok3;
ok3 = [1].map!("a*1")().array();
Comment #2 by bearophile_hugs — 2012-03-28T04:32:21Z
This program:
import std.algorithm, std.array;
void main() {
__gshared r = [1].map!q{a * 1}();
}
gives to me (2.059head, 32 bit Windows):
...\dmd2\src\phobos\std\algorithm.d(461): Error: nested structs with constructors are not yet supported in CTFE (Bug 6419)
test.d(3): called from here: map([1])
Comment #3 by clugdbug — 2012-03-29T12:14:29Z
Not a regression - didn't work on any prior release.
Comment #4 by simendsjo — 2012-03-29T12:23:33Z
Pretty sure it worked at the start of this week.
Comment #5 by k.hara.pg — 2012-03-29T20:59:35Z
I'm not sure what is wrong. __gshared variable declaration is treated like static variable one (even if it is in local), and its initializer is *always* const-folded by interpretation(== CTFE).
And the behavior is in there from earlier than 2.058. So I'm sure that the expressions have been failed to compile with bug 6419 and this issue never relates to UFCS.
To simendsjo:
Please tell us the exact commit hash of dmd repository that succeeds to compile the code. If you cannot do it, I'll close this bug as "resolved invalid" bug.
Comment #6 by clugdbug — 2012-03-30T16:28:44Z
(In reply to comment #4)
> Pretty sure it worked at the start of this week.
It only gets a 'regression' tag if it worked as part of a release.