[PATCH] D131662: [clang] Try to improve diagnostics about uninitialized constexpr variables

Timm Bäder via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Aug 17 21:58:27 PDT 2022


tbaeder added inline comments.


================
Comment at: clang/lib/Sema/SemaFixItUtils.cpp:208-210
+  if (T->isArrayType()) {
+    return " = {}";
+  }
----------------
aaron.ballman wrote:
> I don't think this is a good change, consider:
> ```
> int array[] = {};
> ```
> zero-sized arrays are an extension in both C and C++, and the empty initializer is a GNU extension in C (at least until C2x).
The code in `SemaInit.cpp` is weird in that it only holds if the fixit isn't empty... so if that change does away, a `constexpr int arr[2];` also doesn't use the new error message :(


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D131662/new/

https://reviews.llvm.org/D131662



More information about the cfe-commits mailing list