Bug 15498 – Unhelpful error message "destructors, postblits and invariants are not allowed in overlapping fields"

Status
RESOLVED
Resolution
WORKSFORME
Severity
enhancement
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
x86_64
OS
Windows
Creation time
2016-01-02T11:33:48Z
Last change time
2018-05-06T20:00:11Z
Assigned to
No Owner
Creator
Manu

Attachments

IDFilenameSummaryContent-TypeSize
1601repo-15498.zipShows Issue 15498application/x-zip-compressed521

Comments

Comment #0 by turkeyman — 2016-01-02T11:33:48Z
This error has been bugging me for hours. I have no idea what it means, or why it's happening. Error: struct libep.componentdesc.ComponentDesc destructors, postblits and invariants are not allowed in overlapping fields info and baseClass There are no unions in sight... what's the deal? Here's the code: struct ComponentInfo { SharedString id; } struct ComponentDesc { ComponentInfo info; SharedString baseClass; } SharedString is: extern(C++, ep) struct SharedString { /+ some stuff +/ } Assuming this is some sort of user error, I would like to suggest that this bug is to improve the error message and tell me what is actually wrong. I can't do anything with this.
Comment #1 by turkeyman — 2016-03-26T15:46:04Z
I'm still stuck on this... what does the error mean?
Comment #2 by schveiguy — 2016-03-26T16:43:11Z
the /+ some stuff +/ might be the cause. I don't see any postblits, invariants, etc. anywhere either. Can you elaborate there? Maybe a minimal reproduction?
Comment #3 by k.hara.pg — 2016-03-28T13:15:28Z
Minimized example code that compiler shows the error message. struct X { this(this) {} // or: ~this() {} // or: invariant {} } union U // Error { X x; int overlapping; } struct S // Error { union { X x; int overlapping; } } For U or S, compiler cannot generate destructors, postblits, or invariants automatically, because the field x typed X overlapping with other fields.
Comment #4 by schveiguy — 2016-03-28T14:23:58Z
(In reply to Kenji Hara from comment #3) > Minimized example code that compiler shows the error message. But what about if there are no unions? Manu says no unions are being used. In his code, there is no unions where the error is being printed (info conflicts with baseClass).
Comment #5 by k.hara.pg — 2016-03-28T14:35:42Z
(In reply to Steven Schveighoffer from comment #4) > But what about if there are no unions? Manu says no unions are being used. > > In his code, there is no unions where the error is being printed (info > conflicts with baseClass). If there's no unions (overlapped fields), the error print would be a compiler bug. Honestly I cannot say anything until I see what the "some stuff" actually is.
Comment #6 by schveiguy — 2016-03-28T14:41:54Z
(In reply to Kenji Hara from comment #5) > If there's no unions (overlapped fields), the error print would be a > compiler bug. > > Honestly I cannot say anything until I see what the "some stuff" actually is. I would also like to see what is in there, but even without that, the error report is at least misleading. Note the error once again: Error: struct libep.componentdesc.ComponentDesc destructors, postblits and invariants are not allowed in overlapping fields info and baseClass And the struct ComponentDesc: struct ComponentDesc { ComponentInfo info; SharedString baseClass; } Is there any way to define ComponentInfo or SharedString such that info and baseClass overlap? I wouldn't think so.
Comment #7 by k.hara.pg — 2016-03-28T15:03:01Z
(In reply to Steven Schveighoffer from comment #6) > Is there any way to define ComponentInfo or SharedString such that info and > baseClass overlap? I wouldn't think so. I don't know. So this is funny issue. I'm waiting more information from Manu.
Comment #8 by joeyemmons — 2016-06-14T03:11:57Z
I am getting this too, definitely don't have any unions. My issue seems to be caused by some kind of import ordering problem, reordering some of my imports makes it go away. Making a minimized reproduction might be hard.
Comment #9 by joeyemmons — 2016-06-14T07:13:44Z
Created attachment 1601 Shows Issue 15498 The error seems to be printed for no reason at all except to confuse things...
Comment #10 by schveiguy — 2016-06-14T11:23:46Z
(In reply to joeyemmons from comment #9) > Created attachment 1601 [details] > Shows Issue 15498 > > The error seems to be printed for no reason at all except to confuse > things... Hm.. definitely the error is confusing, but the code itself has another error (hwCursorRef is not defined). Do you have a reproduction that doesn't involve another error?
Comment #11 by joeyemmons — 2016-06-14T11:32:25Z
(In reply to Steven Schveighoffer from comment #10) > (In reply to joeyemmons from comment #9) > > Created attachment 1601 [details] > > Shows Issue 15498 > > > > The error seems to be printed for no reason at all except to confuse > > things... > > > Hm.. definitely the error is confusing, but the code itself has another > error (hwCursorRef is not defined). > > Do you have a reproduction that doesn't involve another error? No, I only seem to get this error to print when in the presence of other errors, but as far as I can tell this error should not be printing and only confuses things. Really annoying when it pops up and really has nothing to do with the actual problem... very unhelpful...
Comment #12 by Marco.Leise — 2016-07-22T20:51:12Z
Hmm, recently I see different "overlapping fields" error messages popping up after certain types of deprecations are detected on the involved fields. There may be a connection: https://issues.dlang.org/show_bug.cgi?id=16312
Comment #13 by turkeyman — 2018-05-06T20:00:11Z
I can no longer reproduce this.