[Bug c++/70403] A null pointer check removed with -O2 even with -fno-delete-null-pointer-checks
rguenth at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Fri Apr 1 08:17:00 GMT 2016
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70403
Richard Biener <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|WAITING |RESOLVED
Resolution|--- |INVALID
--- Comment #10 from Richard Biener <rguenth at gcc dot gnu.org> ---
The reduced testcase doesn't have the pattern you describe in the description.
With the preprocessed source I can confirm your observation (the NULL pointer
check is gone) with GCC 4.9.2. With GCC 5 the whole function
NewLogicalSwitch::CpSelect is optimized to
<bb 2>:
_profile63.mpRecord = 0B;
_profile63.mThisBufferId = 0;
msEnabled.9_15 = msEnabled;
if (msEnabled.9_15 != 0)
goto <bb 3>;
else
goto <bb 4>;
<bb 3>:
ProfilePoint::Enter (&_profile63, &__PRETTY_FUNCTION__, 0);
<bb 4>:
tbrGet ();
<bb 5>:
*rFailureReason_5(D) = 0;
__builtin_unreachable ();
<L125>:
msEnabled.10_16 = msEnabled;
if (msEnabled.10_16 != 0)
goto <bb 7>;
else
goto <bb 8>;
<bb 7>:
ProfilePoint::Exit (&_profile63);
<bb 8>:
_14 = __builtin_eh_pointer (2);
__builtin_unwind_resume (_14);
which means there is something wrong with your code. Very likely it is
McCpId* pCpId = static_cast<McCpId*>(&newCpId);
and it's further use. You can't use an object of McId via a pointer to
McCpId but you call
pCpId->toString (cpIdBuf, sizeof (cpIdBuf));
on it.
More information about the Gcc-bugs
mailing list