[clang] [Clang][CodeGen] Emit load of GEP after EmitMemberExpr (PR #110487)
Jan Hendrik Farr via cfe-commits
cfe-commits at lists.llvm.org
Mon Sep 30 04:24:43 PDT 2024
Cydox wrote:
Wait, this introduces a regression when the inner struct is directly nested without using a pointer like so:
Without this change the code below will return 64, with my fix it will also return 64, with this fix it will SEGFAULT.
```C
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
struct variable {
int a;
int b;
int length;
short array[] __attribute__((counted_by(length)));
};
struct bucket {
int a;
struct variable growable;
// struct variable *growable;
// int b;
};
int main(int argc, char *argv[])
{
struct bucket *p;
struct variable *v;
p = malloc(sizeof(*p) + sizeof(*p->growable.array) * 32);
p->growable.length = 32;
// printf("%zu\n", __builtin_dynamic_object_size(v->array, 1));
// p->growable = v;
printf("%zu\n", __builtin_dynamic_object_size(p->growable.array, 1));
return 0;
}
```
https://github.com/llvm/llvm-project/pull/110487
More information about the cfe-commits
mailing list