[PATCH] Fix __cxa_exception ABI breakage in 4.4 (PR libstdc++/38732)

Jakub Jelinek jakub@redhat.com
Wed Jan 7 17:54:00 GMT 2009


On Wed, Jan 07, 2009 at 05:28:30PM +0100, Richard Guenther wrote:
> On Wed, Jan 7, 2009 at 5:23 PM, Paolo Carlini <paolo.carlini@oracle.com> wrote:
> > Ok. First blush all those reinterpret_cast made me nervous about
> > possible aliasing issues, but then I noticed that you are following
> > existing practice in unwind-cxx.h, thus everything should be fine... (if
> > you could double check that -Wstrict-aliasing is always happy both
> > during the build and the testing, before committing, it would be great)

unwind-cxx.h isn't exported header, so only libsupc++ building matters.
With -Wstrict-aliasing{,=2,=3} no warnings are reported, with
-O2 -D_GNU_SOURCE -Wstrict-aliasing=1
In file included from ../../../../libstdc++-v3/libsupc++/eh_alloc.cc:41:
../../../../libstdc++-v3/libsupc++/unwind-cxx.h: In function ‘__cxxabiv1::__cxa_exception* __cxxabiv1::__get_exception_header_from_ue(_Unwind_Exception*)’:
../../../../libstdc++-v3/libsupc++/unwind-cxx.h:232: warning: dereferencing type-punned pointer might break strict-aliasing rules
../../../../libstdc++-v3/libsupc++/unwind-cxx.h: In function ‘__cxxabiv1::__cxa_refcounted_exception* __cxxabiv1::__get_refcounted_exception_header_from_ue(_Unwind_Exception*)’:
../../../../libstdc++-v3/libsupc++/unwind-cxx.h:247: warning: dereferencing type-punned pointer might break strict-aliasing rules
../../../../libstdc++-v3/libsupc++/unwind-cxx.h: In function ‘__cxxabiv1::__cxa_dependent_exception* __cxxabiv1::__get_dependent_exception_from_ue(_Unwind_Exception*)’:
../../../../libstdc++-v3/libsupc++/unwind-cxx.h:253: warning: dereferencing type-punned pointer might break strict-aliasing rules
but two of the 3 warnings are preexisting.  Yet I fail to see how
it violates strict aliasing.  We have:
struct A { ... struct B { ... struct C { ... }; }; };
and just do some up/downcasts.
Either we cast pointers to the end of all of these (the same) to
one of these structs, subtract one and then dereference fields in it,
or first add 1 to pointer to one of these structs (to get to the end)
and then cat/subtract.

	Jakub



More information about the Gcc-patches mailing list