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

Patrick Palka <ppalka at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Last reconfirmed|                            |2026-08-31
             Status|UNCONFIRMED                 |NEW
            Summary|[C++26] Wrong code:         |[14/15/16/17 Regression]
                   |constexpr folding disagrees |[C++26] Wrong code:
                   |with strict constant        |constexpr folding disagrees
                   |evaluation and runtime      |with strict constant
                   |(-std=c++2c only)           |evaluation and runtime
                   |                            |(-std=c++2c only)
   Target Milestone|---                         |14.5
     Ever confirmed|0                           |1
                 CC|                            |jason at gcc dot gnu.org,
                   |                            |ppalka at gcc dot gnu.org
           Keywords|                            |wrong-code
           See Also|                            |https://gcc.gnu.org/bugzill
                   |                            |a/show_bug.cgi?id=110344

--- Comment #1 from Patrick Palka <ppalka at gcc dot gnu.org> ---
Started with r14-2146 "c++: C++26 constexpr cast from void* [PR110344]"

Reduced (compiles OK with -std=c++23, wrong code with -std=c++26, due to
seemingly buggy constexpr evaluation of the 'p' initializer):

constexpr bool parse(const char *str, int len) {
  int start = 0;
  while (start <= len) {
    char *p = (char *)__builtin_memchr(str + start, '.', len - start);
    int end = p ? p - str : len;
    for (; start < end; ++start)
      if (str[start] < '0' || str[start] > '9')
        return false;
    start = end + 1;
  }
  return true;
}
int main() {
  bool ok = parse("123.456.789", 11);
  if (!ok)
    __builtin_abort();
}

Reply via email to