Bug 16627 – [Reg 2.072] non-static structs with postblit/dtor fields are now nested

Status
RESOLVED
Resolution
FIXED
Severity
regression
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2016-10-19T23:11:59Z
Last change time
2018-12-21T05:29:46Z
Assigned to
No Owner
Creator
Martin Nowak
See also
https://issues.dlang.org/show_bug.cgi?id=16607

Comments

Comment #0 by code — 2016-10-19T23:11:59Z
cat > bug.d << CODE void bug(A...)(ref A args) { struct S { A expand; } // no references static assert(!__traits(isNested, S)); // suddenly nested } struct SNoCopy { @disable this(this); } void test() { SNoCopy itm; bug(itm); } CODE dmd -c bug ---- Apparently caused by https://github.com/dlang/dmd/pull/5500.
Comment #1 by code — 2016-10-19T23:25:45Z
Comment #2 by code — 2016-10-24T01:36:06Z
This happens because structs are converted to nested structs by the semantic analysis of their member functions. The idea behind this seems to be that struct without methods can't access the outer frame, hence never need nesting. Could be reconsidered to be deprecated in favor of explicit `static struct` or a proper detection of closure access. With dlang/dmd#5500 the dependency of the generate postblits/dtors on a finalized struct size was removed, now semantic just collects a list of fields and finalizes the size later on. This resolves some problems w/ forward references. Previously __fieldPostblit and __fieldDtor were generated after finalizing the size and didn't convert structs to a nested one due to a `if (sizeok == SIZEOKdone) return;` check in makeNested. Now semantic for those functions runs before the finalization and does convert structs to nested. This bug only affects structs w/o any other function (b/c those would be nested already) and at least one field w/ dtor/postblit.
Comment #3 by github-bugzilla — 2016-10-25T04:44:16Z
Commits pushed to stable at https://github.com/dlang/dmd https://github.com/dlang/dmd/commit/868ce84e30a3d4e1157e9e72bc3e308b0cd0b1db fix Issue 16627 - non-static structs with postblit/dtor fields now nested - Since dlang/dmd#5500 buildPostblit/Dtor/OpAssign are run before the struct size is finalized, thereby now making structs nested that previously were not. - Not sure if the old behavior was an intended feature. If not we might want to deprecate it. https://github.com/dlang/dmd/commit/8e8541a941bb8fdacf6c8b7a042a69cf77d4676c Merge pull request #6212 from MartinNowak/fix16627 fix Issue 16627 - non-static structs with postblit/dtor fields now nested
Comment #4 by github-bugzilla — 2016-11-05T03:41:37Z
Commits pushed to master at https://github.com/dlang/dmd https://github.com/dlang/dmd/commit/868ce84e30a3d4e1157e9e72bc3e308b0cd0b1db fix Issue 16627 - non-static structs with postblit/dtor fields now nested https://github.com/dlang/dmd/commit/8e8541a941bb8fdacf6c8b7a042a69cf77d4676c Merge pull request #6212 from MartinNowak/fix16627
Comment #5 by github-bugzilla — 2016-12-27T14:40:46Z
Commits pushed to scope at https://github.com/dlang/dmd https://github.com/dlang/dmd/commit/868ce84e30a3d4e1157e9e72bc3e308b0cd0b1db fix Issue 16627 - non-static structs with postblit/dtor fields now nested https://github.com/dlang/dmd/commit/8e8541a941bb8fdacf6c8b7a042a69cf77d4676c Merge pull request #6212 from MartinNowak/fix16627
Comment #6 by github-bugzilla — 2017-01-16T23:24:00Z
Commits pushed to newCTFE at https://github.com/dlang/dmd https://github.com/dlang/dmd/commit/868ce84e30a3d4e1157e9e72bc3e308b0cd0b1db fix Issue 16627 - non-static structs with postblit/dtor fields now nested https://github.com/dlang/dmd/commit/8e8541a941bb8fdacf6c8b7a042a69cf77d4676c Merge pull request #6212 from MartinNowak/fix16627