ahatanak wrote:
clang started issuing a warning after this PR was merged when compiling the
following code:
```
typedef long unsigned int size_t;
extern "C" {
void *
memcpy(void * __dst, const void * __src,
size_t __n);
}
struct MyClass
{
unsigned numberOfBuffers;
unsigned long long buffers[1];
};
typedef struct MyClass MyClass;
MyClass a0;
void test() {
const size_t byteSize = sizeof(MyClass) + sizeof(unsigned long long);
MyClass &a1 = *(MyClass *)__builtin_alloca(byteSize);
MyClass *a2 = (MyClass *)__builtin_alloca(byteSize);
memcpy(&a1.buffers[0], &a0.buffers[0], sizeof(unsigned long long)); // no
warnings.
memcpy(&a1.buffers[1], &a0.buffers[0], sizeof(unsigned long long)); //
warning: 'memcpy' will always overflow; destination buffer has size 0, but size
argument is 8 [-Wfortify-source]
memcpy(a2->buffers[1], &a0.buffers[0], sizeof(unsigned long long)); // no
warnings.
}
```
Is the warning valid? Is the change in clang's behavior intentional?
https://github.com/llvm/llvm-project/pull/95474
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits