[PATCH] Fix canonical types w/ transparent unions (4.3 regression, PR c++/35315)
Doug Gregor
doug.gregor@gmail.com
Thu Feb 28 21:47:00 GMT 2008
Here's a slightly improved patch, which moves the canonical-types fix
into build_duplicate_type. I'll commit to mainline tomorrow if there
are no objections. However, I'm pinging Mark and Jakub to ask whether
this is patch should also go into 4.3. I believe the answer is "no",
but here's some reasoning.
Any failure in the canonical types system is bad; it changes the
notion of type identity in C++, which will break programs. Thankfully,
we have a fallback with the verify-canonical-types parameter. My
initial panic over this issue was due to the use of transparent_union
in a glibc header (stdlib.h, nonetheless):
# if !defined __GNUC__ || __GNUC__ < 2 || defined __cplusplus
# define __WAIT_STATUS void *
# define __WAIT_STATUS_DEFN void *
# else
/* This works in GCC 2.6.1 and later. */
typedef union
{
union wait *__uptr;
int *__iptr;
} __WAIT_STATUS __attribute__ ((__transparent_union__));
# define __WAIT_STATUS_DEFN int *
# endif
But now that I've noticed the "|| defined __cplusplus", I'm not quite
as worried, because C doesn't use the canonical types system. So,
transparent_unions in C++ won't work entirely correctly in 4.3.0, but
I imagine it's a little-used feature in the C++ world. If I'm wrong,
we should accept this little patch.
- Doug
2008-02-26 Douglas Gregor <doug.gregor@gmail.com>
PR c++/35315
* tree-inline.c (build_duplicate_type): When we make a
duplicate type, make it unique in the canonical types system.
2008-02-26 Douglas Gregor <doug.gregor@gmail.com>
PR c++/35315
* g++.dg/ext/attrib32.C: Add another test case.
On Mon, Feb 25, 2008 at 11:15 PM, Doug Gregor <doug.gregor@gmail.com> wrote:
> This is a simple canonical-types fix for dealing with transparent
> union attributes properly in the canonical-types system. We just need
> to set the TYPE_CANONICAL for the transparent_union variant of a type
> appropriately. This fixes PR c++/35315, a canonical-types regression.
>
> Okay for mainline? Should it also go into the 4.3 branch?
>
> - Doug
>
> 2008-02-25 Douglas Gregor <doug.gregor@gmail.com>
>
> PR c++/35315
> * c-common.c (handle_transparent_union_attribute): When we make a
> duplicate type, make it unique in the canonical types system.
>
> 2008-02-25 Douglas Gregor <doug.gregor@gmail.com>
>
> PR c++/35315
> * g++.dg/ext/transparent_union.C: New.
>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: transparent-union-canon.patch
Type: application/octet-stream
Size: 747 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20080228/80bbdfc8/attachment.obj>
More information about the Gcc-patches
mailing list