This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug tree-optimization/30252] [4.2 regression] miscompilation of sigc++-2.0 based code with -fstrict-aliasing
- From: "bangerth at math dot tamu dot edu" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 1 May 2007 01:39:19 -0000
- Subject: [Bug tree-optimization/30252] [4.2 regression] miscompilation of sigc++-2.0 based code with -fstrict-aliasing
- References: <bug-30252-7958@http.gcc.gnu.org/bugzilla/>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Comment #14 from bangerth at math dot tamu dot edu 2007-05-01 02:39 -------
Subject: Re: [4.2 regression] miscompilation
of sigc++-2.0 based code with -fstrict-aliasing
> > typedef typed_slot_rep<T_functor> typed_slot;
> > typed_slot *typed_rep = static_cast<typed_slot*>(rep);
> > return (typed_rep->functor_)();
> >
> > This code could violate C++ aliasing rules.
>
> But:
> template <class T_functor>
> struct typed_slot_rep : public slot_rep
>
> so it looks like it might be valid.
But only, of course, if the pointer actually points to a typed_slot_rep.
Maybe someone who can reproduce the bug can make the following test:
- add a virtual destructor to slot_rep
- change the static_cast to a dynamic_cast
If the object pointed to is not a typed_slot_rep (in which the static_cast
in the original code would have been in error), then the code should
probably segfault or so...
W.
-------------------------------------------------------------------------
Wolfgang Bangerth email: bangerth@math.tamu.edu
www: http://www.math.tamu.edu/~bangerth/
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=30252