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

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           See Also|                            |https://gcc.gnu.org/bugzill
                   |                            |a/show_bug.cgi?id=109571

--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
PR 109571 is basically the same here just with a different warning (and
upcasting instead of downcasting).

In this case if we look at:
void nsJSPrincipals::Destroy(JSPrincipals* jsprin) {
 nsJSPrincipals* nsjsprin = nsJSPrincipals::get(jsprin);


if jsprin is null, then nsjsprin needs to be null too. And since nsjsprin ==
jsprin-8(bytes) (if it was a valid pointer), the C++ front-end needs to add a
check for null. And then the optimizations come along and does jump threading.
so one way of removing this is adding an assumption which can be done via one
of the following:
  if (!jsprin) __builtin_unreachable();
  [[assume(jsprin)]];

The first one is valid for GCC all the way back in 4.7 (and before).
the second one is C++23 and was only added in GCC 13.

Reply via email to