[clang] [clang] Reject VLAs in `__is_layout_compatible()` (PR #87737)

Aaron Ballman via cfe-commits cfe-commits at lists.llvm.org
Fri Apr 5 04:59:05 PDT 2024


AaronBallman wrote:

> We should not reject (ie, make the programm ill-form) _any_ type. Just return `false` in all of these cases

GCC rejects incomplete types: https://godbolt.org/z/xWbes5Wsc
Both Clang and GCC reject instantiating templates with VLAs but accept it in the builtin: https://godbolt.org/z/b95GEGcGx
Both Clang and GCC accept flexible arrays: https://godbolt.org/z/fWbfExMTb

I think the behavior from GCC is defensible, so I think we should reject incomplete types, but accept flexible arrays. VLAs I'm ambivalent about because of the template instantiation behavior. CC @ldionne @philnik777 @mordante for libc++ perspective.

https://github.com/llvm/llvm-project/pull/87737


More information about the cfe-commits mailing list