tavianator wrote:

> The expression can be simplified to ... As the padding at the end of the 
> structure is always smaller than the alignof. So `round_up(alignof(struct S), 
> offsetof(struct S, fam)) = sizeof(struct S)`

I think that's right for sane ABIs.  I assume Clang always lays structs out 
like this.

My use of `max(sizeof(struct S))` was to support pathological compilers that 
add unnecessary padding.  But it doesn't completely handle pathological 
compilers, since they may also pad

```c
struct S {
    int foo;
    char fam[N];
};
```

unnecessarily and you can't really predict that.  Ignoring that case, your 
simplification seems fine to me.

https://github.com/llvm/llvm-project/pull/112636
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to