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

Jonathan Wakely <redi at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Last reconfirmed|                            |2023-08-21
     Ever confirmed|0                           |1
             Status|UNCONFIRMED                 |NEW

--- Comment #10 from Jonathan Wakely <redi at gcc dot gnu.org> ---
The warning in this case is idiotic:

#include <algorithm>
#include <array>
#include <string_view>

const std::array<std::string_view, 0> tags{};

bool hasTag(const char* const tag) {
  const auto result = std::lower_bound(tags.begin(), tags.end(), tag);
  if (result == tags.end())
    return false;
  if (!result)
    return false;
  if (result)
    return result->compare(tag) == 0;
}

null.cc: In function 'bool hasTag(const char*)':
null.cc:14:12: warning: 'this' pointer is null [-Wnonnull]
   14 |     return result->compare(tag) == 0;
      |            ^~~~~~
In file included from null.cc:3:
/home/jwakely/gcc/14/include/c++/14.0.0/string_view:364:7: note: in a call to
non-static member function 'constexpr int std::basic_string_view<_CharT,
_Traits>::compare(const _CharT*) const [with _CharT = char; _Traits =
std::char_traits<char>]'
  364 |       compare(const _CharT* __str) const noexcept
      |       ^~~~~~~


Confirmed as a bug.

Reply via email to