[clang] [Sema] Fix crash on invalid code with parenthesized aggregate initialization (PR #76232)

Ilya Biryukov via cfe-commits cfe-commits at lists.llvm.org
Tue Jan 2 05:13:40 PST 2024


ilya-biryukov wrote:

Thanks for reverting it and sorry for the trouble, I will make sure to check libc++ tests before a reland.
Clang does report less errors now, but that's expected. The errors were spurious, caused by Clang trying to initialize an "invalid" class (more details below in case you're interested).

Failed `static_assert` is what made the class invalid in the first place and Clang fails parenthesized initialization of such classes early now. We should not do parenthesized initialization here as it should only be applied to aggregates, this class has constructors and is not an aggregate in the first place. The only reason we attempted aggregate init is because invalid classes are left internally in inconsistent states sometimes (there are many reasons why class is invalid). So less errors is better here, they were only adding noise and confusion in the first place.

I will reland the commit with updated libc++ tests. The commit did not change the set of correct programs that we compile, it's just showing less spurious errors.

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


More information about the cfe-commits mailing list