Details
- Reviewers
aaron.ballman - Group Reviewers
Restricted Project - Commits
- rGaaaece65a80f: [clang][ExprConst] Handle 0 type size in builtin_memcpy etc.
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
clang/lib/AST/ExprConstant.cpp | ||
---|---|---|
9548 | I think we should issue a diagnostic, we don't have any indication that this is failing, let alone because the destination object size is zero. |
clang/lib/AST/ExprConstant.cpp | ||
---|---|---|
9548 | You mean in addition to the one we are emitting? |
clang/test/Sema/builtin-memcpy.c | ||
---|---|---|
5–9 | 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.) |
clang/test/Sema/builtin-memcpy.c | ||
---|---|---|
5–9 | Nope, clang accepts that and GCC rejects the function when calling. |
LGTM with a fixme comment added.
clang/test/Sema/builtin-memcpy.c | ||
---|---|---|
5–9 | Amusingly, Clang and EDG (GNU mode) accept and GCC rejects. GCC is correct, so it's worth adding a FIXME to the case below so we know this isn't intentional behavior. |
I think we should issue a diagnostic, we don't have any indication that this is failing, let alone because the destination object size is zero.