[Bug c++/101480] [11/12 Regression] Miscompiled code involving operator new

msebor at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Wed Jul 28 17:16:06 GMT 2021


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101480

Martin Sebor <msebor at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |msebor at gcc dot gnu.org

--- Comment #16 from Martin Sebor <msebor at gcc dot gnu.org> ---
(In reply to Richard Biener from comment #14)
...
> the testcase does
> 
>     m = i;
>     p = (int*) new unsigned char [sizeof (int) * m];
> 
>     for (int i = 0; i < m; i++)
>       new (p + i) int ();
> 
> and we likely have to assume that 'new' changes 'm'.

Why?  Because of the flow-insensitivity of the alias analysis?

m is a member of the class whose ctor has the loop above.  Neither the
enclosing object nor the member actually escapes (the operator new to which p
is passed in the loop is the nonreplaceable placement new), so there is no way
it can be changed.


More information about the Gcc-bugs mailing list