D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 13191 - Silenced forward struct reference error
Summary: Silenced forward struct reference error
Status: RESOLVED WORKSFORME
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: All All
: P1 normal
Assignee: No Owner
URL:
Keywords: diagnostic
Depends on:
Blocks:
 
Reported: 2014-07-22 18:08 UTC by Orvid King
Modified: 2020-03-21 03:56 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Orvid King 2014-07-22 18:08:11 UTC
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 basile-z 2019-03-20 21:21:10 UTC
correct message with "forward reference" nowadays