[Bug tree-optimization/109568] Spurious "potential null pointer dereference" in shared_ptr_base.h with "-O1"

2023-04-20 Thread pinskia at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109568

Andrew Pinski  changed:

   What|Removed |Added

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

--- Comment #7 from Andrew Pinski  ---
This is basically similar to PR 109571 except using dynamic_cast rather than a
downcast. But the same issue is there from jump threading from code emitted
from the front-end.

[Bug tree-optimization/109568] Spurious "potential null pointer dereference" in shared_ptr_base.h with "-O1"

2023-04-20 Thread pinskia at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109568

Andrew Pinski  changed:

   What|Removed |Added

Summary|[12/13/14 Regression]   |Spurious "potential null
   |Spurious "potential null|pointer dereference" in
   |pointer dereference" in |shared_ptr_base.h with
   |shared_ptr_base.h with  |"-O1"
   |"-O1"   |
  Component|libstdc++   |tree-optimization
   Target Milestone|12.3|---

--- Comment #6 from Andrew Pinski  ---
This has nothing to do with libstd++, a similar warning can happen with:
struct Base {
virtual ~Base() = default;
int b = 0;
};

struct Derived : public Base {};

bool empty(Base* var) {
auto* var_ref = dynamic_cast(var);
if (var_ref->b) return false;
return true;
}