Bug 32135 - gcc cannot pick a member of an union to initialize to
gcc cannot pick a member of an union to initialize to
Product: Red Hat Linux
Classification: Retired
Component: gcc (Show other bugs)
i386 Linux
medium Severity medium
: ---
: ---
Assigned To: Jakub Jelinek
David Lawrence
Depends On:
  Show dependency treegraph
Reported: 2001-03-18 14:37 EST by Alex Mao
Modified: 2007-04-18 12:32 EDT (History)
0 users

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Last Closed: 2001-03-20 07:15:59 EST
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---

Attachments (Terms of Use)

  None (edit)
Description Alex Mao 2001-03-18 14:37:16 EST
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.

Reproducible: Always
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.
Comment 1 Jakub Jelinek 2001-03-20 07:48:02 EST
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.

Note You need to log in before you can comment on or make changes to this bug.