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

programmer at posteo dot de changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |programmer at posteo dot de

--- Comment #6 from programmer at posteo dot de ---
The same bogus warning ist produced by "g++ -Wall" with the C++ code below.
Note that flexible array members are not involved there.

GCC 9.2 is affected: https://godbolt.org/z/j9m4XS
GCC 10 seems fixed: https://godbolt.org/z/DPrR1Z

//////////////////////////////////////////////////////////////////////////////

struct two_chars_t {// std::array<char, 2>
  char data_[2];
  constexpr const char* data() const { return data_; }
};

constexpr two_chars_t global_x0  = two_chars_t{'x', '\0'};

int main() {
  constexpr const char* pointer = global_x0.data();

  static_assert(pointer[0] == 'x');
  static_assert(pointer[1] == '\0');

  return __builtin_strlen(pointer);
}

//////////////////////////////////////////////////////////////////////////////

Reply via email to