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

--- Comment #8 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
(In reply to Martin Jambor from comment #7)
> (In reply to Jakub Jelinek from comment #4)
> >
> > ...
> > 
> > The statement on which on the original testcase it warns indeed has no
> > location, that was created during IPA optimizations:
> > ipa_modify_call_arguments does:
> >           loc = DECL_P (base) ? DECL_SOURCE_LOCATION (base)
> >                               : EXPR_LOCATION (base);
> > This itself is weird in this case, base is a SSA_NAME this_4(D), so has no
> > location and loc is UNKNOWN_LOCATION.
> 
> Interesting, I see base being an ADDR_EXPR on trunk.  But anyway...

Are you looking at the #c0 testcase or the reduced one?  The reduced one only
shows the -Wnull-dereference warning, with correct location.
Only the original one has the UNKNOWN_LOCATION on the statement on which the
warning is emitted.

> That might indeed make more sense, I will look into it.
> 
> But please note that I get exactly the same warning when I add
> -fno-ipa-sra on the command line (and I have verified in gdb that
> ipa_modify_call_arguments is not invoked at all with the option just
> to double check) so ipa_modify_call_arguments cannot be the whole
> story.

-fno-ipa-sra makes the warning go away altogether for me on the trunk on the
original testcase:
./cc1plus -quiet -std=c++17 -O3 -Wnull-dereference pr83990.ii; echo ===; \
./cc1plus -quiet -std=c++17 -O3 -Wnull-dereference pr83990.ii -fno-ipa-sra; \
echo ===
In function ‘void std::vector<_Tp, _Alloc>::reserve(std::vector<_Tp,
_Alloc>::size_type) [with _Tp = std::__cxx11::basic_string<char>; _Alloc =
std::allocator<std::__cxx11::basic_string<char> >]’:
cc1plus: warning: potential null pointer dereference [-Wnull-dereference]
===
===

Reply via email to