[PATCH] D157252: [clang][ExprConst] Handle 0 type size in builtin_memcpy etc.
Timm Bäder via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Sat Oct 21 09:53:20 PDT 2023
tbaeder added inline comments.
================
Comment at: clang/test/Sema/builtin-memcpy.c:4-8
+int b() {
+ struct { } a[10];
+ __builtin_memcpy(&a[2], a, 2); // expected-warning {{buffer has size 0, but size argument is 2}}
+ return 0;
+}
----------------
aaron.ballman wrote:
> The only other test I'd like to see is one like:
> ```
> constexpr int b() {
> struct { } a[10];
> __builtin_memcpy(&a[2], a, 2); // UB here should be caught, right?
> return 0;
> }
>
> static_assert(b() == 0, "");
> ```
> (if that's follow-up work, that's fine too, just leave a test with a FIXME comment.)
Nope, clang accepts that and GCC rejects the function when calling.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D157252/new/
https://reviews.llvm.org/D157252
More information about the cfe-commits
mailing list