[clang] [Clang] Fixed the behavior of C23 auto when an array type was specified for a `char *` (PR #189722)

Aaron Ballman via cfe-commits cfe-commits at lists.llvm.org
Wed Apr 1 07:53:01 PDT 2026


================
@@ -107,12 +107,11 @@ void test_misc(void) {
   auto something;                           // expected-error {{declaration of variable 'something' with deduced type 'auto' requires an initializer}}
   auto test_char = 'A';
   auto test_char_ptr = "test";
-  auto test_char_ptr2[] = "another test";   // expected-warning {{type inference of a declaration other than a plain identifier with optional trailing attributes is a Clang extension}}
+  auto test_char_ptr2[] = "another test";   // expected-error {{variable 'test_char_ptr2' with type 'auto[]' has incompatible initializer of type 'char[13]'}}
----------------
AaronBallman wrote:

I think the current behavior is defensible, but this seems worth a bit more investigation; I think the other two diagnostics are easier for the user to know what's going wrong with their code.

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


More information about the cfe-commits mailing list