D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 7788 - __gshared and UFCS - "Error: nested structs with constructors are not yet supported in CTFE (Bug 6419)"
Summary: __gshared and UFCS - "Error: nested structs with constructors are not yet sup...
Status: RESOLVED INVALID
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: All Linux
: P2 normal
Assignee: No Owner
URL:
Keywords: rejects-valid
Depends on:
Blocks:
 
Reported: 2012-03-28 00:41 UTC by simendsjo
Modified: 2012-04-04 11:58 UTC (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description simendsjo 2012-03-28 00:41:09 UTC
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 simendsjo 2012-03-28 00:44:40 UTC
Oh, and the following works too:

    __gshared int[] ok3;
    ok3 = [1].map!("a*1")().array();
Comment 2 bearophile_hugs 2012-03-28 04:32:21 UTC
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 Don 2012-03-29 12:14:29 UTC
Not a regression - didn't work on any prior release.
Comment 4 simendsjo 2012-03-29 12:23:33 UTC
Pretty sure it worked at the start of this week.
Comment 5 Kenji Hara 2012-03-29 20:59:35 UTC
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 Don 2012-03-30 16:28:44 UTC
(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.