Bug 32135 - gcc cannot pick a member of an union to initialize to
Summary: gcc cannot pick a member of an union to initialize to
Keywords:
Status: CLOSED NOTABUG
Alias: None
Product: Red Hat Linux
Classification: Retired
Component: gcc
Version: 7.0
Hardware: i386
OS: Linux
medium
medium
Target Milestone: ---
Assignee: Jakub Jelinek
QA Contact: David Lawrence
URL: http://arioch.despayre.ath.cx/gccbug....
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2001-03-18 19:37 UTC by Alex Mao
Modified: 2007-04-18 16:32 UTC (History)
0 users

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2001-03-20 12:15:59 UTC
Embargoed:


Attachments (Terms of Use)

Description Alex Mao 2001-03-18 19:37:16 UTC
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 12:48:02 UTC
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.