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

            Bug ID: 117355
           Summary: [15 regression] firebird miscompiled
           Product: gcc
           Version: 15.0
            Status: UNCONFIRMED
          Keywords: wrong-code
          Severity: normal
          Priority: P3
         Component: middle-end
          Assignee: unassigned at gcc dot gnu.org
          Reporter: sjames at gcc dot gnu.org
  Target Milestone: ---

Originally reported downstream in Gentoo at https://bugs.gentoo.org/942205.

With -D_FORTIFY_SOURCE=2/3, this aborts with trunk:
```
#include <cstdint>
#include <cstdio>
#include <cstring>

static void gen_blr(const char *string) {
  char line[256];
  const char *p = string;

  int length = static_cast<int>(strlen(p));
  const char *q;
  q = p + strlen(p);

  char *q1 = line;
  for (const char *p1 = p; p1 < q;) {
    if ((*q1++ = *p1++) == 'g') {
      if (p1 < q && (*q1++ = *p1++) == 'd') {
        if (p1 < q && (*q1++ = *p1++) == 's') {
          if (p1 < q && (*q1++ = *p1++) == '_') {
            char d = 0;
            if (p1 < q && ((d = *p1++) == '_' || d == '$')) {
              strncpy(q1 - 4, "isc", 3);
            }
          }
        }
      }
    }
  }
}

int main() { gen_blr("string gds__)"); }
```

Reply via email to