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

2024-04-05 Thread Vlad Serebrennikov via cfe-commits
https://github.com/Endilll closed https://github.com/llvm/llvm-project/pull/87737 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

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

2024-04-05 Thread Shafik Yaghmour via cfe-commits
@@ -1741,8 +1741,10 @@ void is_layout_compatible(int n) static_assert(!__is_layout_compatible(unsigned char, signed char)); static_assert(__is_layout_compatible(int[], int[])); static_assert(__is_layout_compatible(int[2], int[2])); -

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

2024-04-05 Thread Vlad Serebrennikov via cfe-commits
https://github.com/Endilll updated https://github.com/llvm/llvm-project/pull/87737 >From ef24f642ca78d357018d6023fb3d9011f115299b Mon Sep 17 00:00:00 2001 From: Vlad Serebrennikov Date: Fri, 5 Apr 2024 06:22:35 +0300 Subject: [PATCH 1/2] [clang] Reject VLAs in `__is_layout_compatible()` This

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

2024-04-05 Thread via cfe-commits
https://github.com/cor3ntin approved this pull request. Following discussions, LGTM but I'd like to make sure incomplete types don't fall through the cracks https://github.com/llvm/llvm-project/pull/87737 ___ cfe-commits mailing list

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

2024-04-05 Thread Vlad Serebrennikov via cfe-commits
@@ -1741,8 +1741,10 @@ void is_layout_compatible(int n) static_assert(!__is_layout_compatible(unsigned char, signed char)); static_assert(__is_layout_compatible(int[], int[])); static_assert(__is_layout_compatible(int[2], int[2])); -

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

2024-04-05 Thread Aaron Ballman via cfe-commits
@@ -1741,8 +1741,10 @@ void is_layout_compatible(int n) static_assert(!__is_layout_compatible(unsigned char, signed char)); static_assert(__is_layout_compatible(int[], int[])); static_assert(__is_layout_compatible(int[2], int[2])); -

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

2024-04-05 Thread Vlad Serebrennikov via cfe-commits
@@ -1741,8 +1741,10 @@ void is_layout_compatible(int n) static_assert(!__is_layout_compatible(unsigned char, signed char)); static_assert(__is_layout_compatible(int[], int[])); static_assert(__is_layout_compatible(int[2], int[2])); -

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

2024-04-05 Thread Aaron Ballman via cfe-commits
@@ -1741,8 +1741,10 @@ void is_layout_compatible(int n) static_assert(!__is_layout_compatible(unsigned char, signed char)); static_assert(__is_layout_compatible(int[], int[])); static_assert(__is_layout_compatible(int[2], int[2])); -

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

2024-04-05 Thread Aaron Ballman via cfe-commits
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

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

2024-04-05 Thread Vlad Serebrennikov via cfe-commits
Endilll 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 >

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

2024-04-05 Thread Nikolas Klauser via cfe-commits
philnik777 wrote: I think clang should reject incomplete types when the standard says so. It doesn't seem particularly useful to accept some special cases but reject incomplete types in general. All the traits should probably be audited once. It looks like Clang has other problematic cases:

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

2024-04-05 Thread via cfe-commits
cor3ntin wrote: The library does require complete types, interesting https://eel.is/c++draft/meta However, at the language level, I cannot find any wording either way. https://github.com/llvm/llvm-project/pull/87737 ___ cfe-commits mailing list

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

2024-04-05 Thread Aaron Ballman via cfe-commits
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:

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

2024-04-05 Thread via cfe-commits
cor3ntin wrote: We should not reject (ie, make the programm ill-form) _any_ type. Just return `false` in all of these cases https://github.com/llvm/llvm-project/pull/87737 ___ cfe-commits mailing list cfe-commits@lists.llvm.org

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

2024-04-05 Thread Vlad Serebrennikov via cfe-commits
Endilll wrote: > I think the current behavior is reasonable-ish. Rejecting specific types is a > bit weird... I think VLA should model incomplete types (but we currently > don't reject that either, which is a bug) > > IE, I would expect __is_layout_compatible to return false in the presence

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

2024-04-05 Thread via cfe-commits
cor3ntin wrote: I think the current behavior is reasonable-ish. Rejecting specific types is a bit weird... I think VLA should model incomplete types (but we currently don't reject that either, which is a bug) IE, I would expect __is_layout_compatible to return false in the presence of VLAs,

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

2024-04-04 Thread via cfe-commits
llvmbot wrote: @llvm/pr-subscribers-clang Author: Vlad Serebrennikov (Endilll) Changes This is a follow-up to #81506. Since `__is_layout_compatible()` is a C++ intrinsic

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

2024-04-04 Thread Vlad Serebrennikov via cfe-commits
https://github.com/Endilll created https://github.com/llvm/llvm-project/pull/87737 This is a follow-up to #81506. Since `__is_layout_compatible()` is a C++ intrinsic