================
@@ -7,7 +7,8 @@
/// Zero-sized structs should not crash.
int b() {
struct { } a[10];
- __builtin_memcpy(&a[2], a, 2); // c-warning {{buffer has size 0, but size
argument is 2}}
+ __builtin_memcpy(&a[2], a, 2); // c-warning {{buffer has size 0, but size
argument is 2}} \
+ // c-warning {{'memcpy' reading 2 bytes from
a region of size 0}}
----------------
jpjepko wrote:
It would if it wasn't part of an array. But here we get the object size from
`Expr::tryEvaluateObjectSize` and by default pass it a BOSType of 0, so
essentially it returns the size of the underlying array (or remaining array for
`&a[2]`). Which I see as matching GCC's behavior.
https://godbolt.org/z/s1Pq77Mxf
https://github.com/llvm/llvm-project/pull/183004
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits