[Bug c++/107521] clang rejects invalid code in libstdc++

jakub at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Fri Nov 4 08:17:14 GMT 2022


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

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jakub at gcc dot gnu.org

--- Comment #3 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
http://eel.is/c++draft/expr.eq#3
only talks about unspecified behavior if one is a pointer to a start of an
object and another to one past the end of another.
I believe we implement that in GCC, try e.g.

constexpr const char *f (const char* a, const char *b) {
  if (a == b)
    return a;

  return b;
}

char a, b;

constexpr const char *k = f(&a, &b);
constexpr const char *l = f(&a, &b + 1);

When string literals are involved, I think this is PR86369 instead, and Jason
said he thinks GCC is correct there, see
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86369#c8


More information about the Gcc-bugs mailing list