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

            Bug ID: 115641
           Summary: GCC crashes on function has attribute
                    `__attribute__((const))`
           Product: gcc
           Version: 15.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: 141242068 at smail dot nju.edu.cn
  Target Milestone: ---

Compiler Explorer: https://gcc.godbolt.org/z/79oo9rsxj

When compiling this with `gcc-trunk -O2`, gcc crashes.
This only occurs in trunk version, older versions like gcc-{12,13,14} are
tested to be normal.
```
#include <stdlib.h>

typedef struct {
  char hours, day, month;
  short year;
} T;

T g (void) {
  T now;
  now.hours = 1;
  now.day = 2;
  now.month = 3;
  now.year = 4;
  return now;
}

__attribute__((const)) T f (void)
{
  T virk = g ();
  return virk;
}

int main ()
{
  if (f ().hours != 1 || f ().day != 2 || f ().month != 3 || f ().year != 4)
    abort ();
  return 0;
}
```

Reply via email to