diff --git a/gcc/c/c-parser.cc b/gcc/c/c-parser.cc
index f3ed61047477ca5816bf825ae92049ede9e0c5d4..44d344fcd32abebe6d0bfef329259ab870a26aca 100644
--- a/gcc/c/c-parser.cc
+++ b/gcc/c/c-parser.cc
@@ -4444,7 +4444,8 @@ c_parser_typeof_specifier (c_parser *parser)
   parens.skip_until_found_close (parser);
   if (ret.spec != error_mark_node)
     {
-      if (is_unqual && TYPE_QUALS (ret.spec) != TYPE_UNQUALIFIED)
+      if (is_unqual
+	  && TYPE_QUALS (strip_array_types (ret.spec)) != TYPE_UNQUALIFIED)
 	ret.spec = TYPE_MAIN_VARIANT (ret.spec);
       if (is_std)
 	{
diff --git a/gcc/testsuite/gcc.dg/c23-typeof-4.c b/gcc/testsuite/gcc.dg/c23-typeof-4.c
new file mode 100644
index 0000000000000000000000000000000000000000..471d082934143deddfbb727d80d420036cd05e34
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/c23-typeof-4.c
@@ -0,0 +1,10 @@
+/* Test C23 typeof and typeof_unqual on qualified arrays (bug 112841).  */
+/* { dg-do compile } */
+/* { dg-options "-std=c23 -pedantic-errors" } */
+
+const int a[] = { 1, 2, 3 };
+int b[3];
+extern typeof (a) a;
+extern typeof (const int [3]) a;
+extern typeof_unqual (a) b;
+extern typeof_unqual (const int [3]) b;