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

            Bug ID: 122645
           Summary: Code breaks between 15.2 and 16.0
           Product: gcc
           Version: 16.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: eczbek.void at gmail dot com
  Target Milestone: ---

https://godbolt.org/z/e8E7d9s3E

This code runs fine when compiled with GCC 15.2 but segfaults when compiled
with GCC 16.0

```
#include <stdint.h>

typedef struct {
    const uint16_t mov1;
    const uint32_t addr;
    const uint16_t mov2;
    const void* const chain;
} __attribute__((packed)) thunk_struct;

int main() {
    struct { void(*fun)(void*, int); } e;
    if (!({
                __label__ trgt;
                int xsetjmp_ret = 0;
                void jmp(void* self, int r) {
                        if (self != jmp) {
                                __builtin_call_with_static_chain(
                                       
((typeof(jmp)*)(intptr_t)((thunk_struct*)self)->addr)(self, r),
                                        ((thunk_struct*)self)->chain
                                );
                        }
                        xsetjmp_ret = r ? r : 1;
                        goto trgt;
                }
                e.fun = jmp;
        trgt:;
                xsetjmp_ret;
        })) {
               
((typeof(e.fun))(intptr_t)((thunk_struct*)(void*)e.fun)->addr)(e.fun, 1);
        }
}
```

Reply via email to