This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] Work around host compiler placement new aliasing bug


Richard Biener wrote:
> On Wed, Jul 29, 2015 at 3:57 PM, Ulrich Weigand <uweigand@de.ibm.com> wrote:
> > Hello,
> >
> > this patch is a workaround for the problem discussed here:
> > https://gcc.gnu.org/ml/gcc-patches/2015-07/msg01597.html
> >
> > The problem is that the new pool allocator code relies on C++ aliasing
> > rules related to placement new (basically, that placement new changes
> > the dynamic type of the referenced memory).  GCC compilers prior to
> > version 4.3 did not implement this rule correctly (PR 29286).
> >
> > When building current GCC with a host compiler that is affected by this
> > bug, and we build with optimization enabled (this typically only happens
> > when building a cross-compiler), the resulting compiler binary may be
> > miscompiled.
> >
> > The patch below attempts to detect this situation by checking whether
> > the host compiler is a version of GCC prior to 4.3 (but stil accepts
> > the -fno-strict-aliasing flag).  If so, -fno-strict-aliasing is added
> > to the flags when building the compiler binary.
> >
> > Tested on i686-linux, and when building an SPU cross-compiler using
> > a gcc 4.1 powerpc64-linux host compiler.
> >
> > OK for mainline?
> 
> Ok if nobody objects.

I've checked this in now.

Thanks,
Ulrich

-- 
  Dr. Ulrich Weigand
  GNU/Linux compilers and toolchain
  Ulrich.Weigand@de.ibm.com


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]