Bug 13191 – Silenced forward struct reference error

Status
RESOLVED
Resolution
WORKSFORME
Severity
normal
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2014-07-22T18:08:11Z
Last change time
2020-03-21T03:56:36Z
Keywords
diagnostic
Assigned to
No Owner
Creator
Orvid King

Comments

Comment #0 by blah38621 — 2014-07-22T18:08:11Z
Currently the following code produces 4 errors, all of which are completly and utterly useless. main.d(7): Error: variable main.SymbolType.PointerData.size conflicts with variable main.SymbolType.PointerData.size at main.d(7) main.d(8): Error: variable main.SymbolType.PointerData.typePointedTo conflicts with variable main.SymbolType.PointerData.typePointedTo at main.d(8) main.d(7): Error: variable main.SymbolType.PointerData.size conflicts with variable main.SymbolType.PointerData.size at main.d(7) main.d(8): Error: variable main.SymbolType.PointerData.typePointedTo conflicts with variable main.SymbolType.PointerData.typePointedTo at main.d(8) struct SymbolType { static struct PointerData { ubyte size; SymbolType typePointedTo; } union { PointerData pointerData; } } However something magical happens when we move the union above the PointerData struct, we get an extra error that we didn't get before: main.d(10): Error: struct main.SymbolType.PointerData no size yet for forward reference This code will never ever be able to compile due to the fact SymbolType is a struct, however that error appears to be getting silenced if the union is after the struct declaration. If the anonomous union is replaced with a named union, the error is no longer dependent on the location of the union declaration. This should really only be producing 1 error, and that is the "no size yet" error. It should also be being displayed on the member that requires the forward reference, in this case, typePointedTo, rather than on the struct declaration itself.
Comment #1 by b2.temp — 2019-03-20T21:21:10Z
correct message with "forward reference" nowadays