fuhsnn / slimcc

C11 compiler with GNU / C23 extensions for x86-64 Linux, able to build Python and PostgreSQL
MIT License
24 stars 3 forks source link

`sizeof` on structs with flexible array member should exclude its size #72

Closed fuhsnn closed 4 months ago

fuhsnn commented 4 months ago
#include <stdio.h>
struct {
  char c;
  char arr[];
} s = {1,2,3};
int main(void) {
    printf("%zu\n",sizeof(s)); // expected 1, got 3
}