Red Hat Bugzilla – Bug 32135
gcc cannot pick a member of an union to initialize to
Last modified: 2007-04-18 12:32:14 EDT
From Bugzilla Helper:
User-Agent: Mozilla/4.0 (compatible; MSIE 5.5; Windows NT 5.0)
When trying to initiate an array of structs with a struct member that is a
union made up function pointer members, gcc does not know how to initiate
to the correct union member, instead picking the first one.
Steps to Reproduce:
See my URL for example.
Expected Results: In gcc 2.95 it would pick the appropriate union member
the function pointer falls under, and the program compiles correctly.
g++ behaviour is correct, you should fix your source:
According to ISO C++ [decl.init.aggr]/15, when a union is initialized
with a brace-enclosed initializer, the braces shall only contain an
initializer for the first member of the union. We used to implicitly
convert function types to void*, so the initializer was deemed valid,
even though it wasn't.