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

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


AaronBallman wrote:

> > However, at the language level, I cannot find any wording either way.
> 
> In my reading, http://eel.is/c++draft/basic.types.general#11 makes any type layout-compatible with itself, and even ignores cv-qualification:
> 
> > Two types cv1 T1 and cv2 T2 are [layout-compatible types](http://eel.is/c++draft/basic.types.general#def:type,layout-compatible) if T1 and T2 are the same type, [layout-compatible enumerations](http://eel.is/c++draft/dcl.enum#def:layout-compatible,enumeration), or [layout-compatible standard-layout class types](http://eel.is/c++draft/class.mem#def:layout-compatible,class)[.](http://eel.is/c++draft/basic.types.general#11.sentence-1)
> 
> I find the gap between core language term and type trait rather unfortunate.

There are a lot of gaps between core language terms and type traits. For another example, copy constructible in the library is quite different from it in the language, volatile types are almost entirely ignored by the library, etc.

At the end of the day, these builtins are intended to be used as the underlying implementation for the type traits, so when in doubt, following the library rules is usually a safe bet.

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


More information about the cfe-commits mailing list