]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
d: Fix ICE in ExprVisitor::visit, at d/expr.cc:2224 [PR123419]
authorIain Buclaw <ibuclaw@gdcproject.org>
Wed, 28 Jan 2026 22:06:23 +0000 (23:06 +0100)
committerIain Buclaw <ibuclaw@gdcproject.org>
Wed, 28 Jan 2026 22:26:47 +0000 (23:26 +0100)
The original assert expected the type of `__traits(initSymbol)' to be
exactly `const(void[])', but because D strips const from arrays to allow
passing slices as mutable ranges to template functions, so it got turned
into `const(void)[]'.

PR d/123419

gcc/d/ChangeLog:

* expr.cc (ExprVisitor::visit (VarExp *)): Adjust assertion.

gcc/testsuite/ChangeLog:

* gdc.dg/pr123419.d: New test.

gcc/d/expr.cc
gcc/testsuite/gdc.dg/pr123419.d [new file with mode: 0644]

index 79d1839f0d6c7050c9bea1dc1523ccfefe029c50..77c9412fd94051b24de7dc984717a77c2157caa4 100644 (file)
@@ -2156,7 +2156,7 @@ public:
              {
                /* Generate a slice for non-zero initialized aggregates,
                   otherwise create an empty array.  */
-               gcc_assert (e->type->isConst ()
+               gcc_assert (e->type->nextOf ()->isConst ()
                            && e->type->nextOf ()->ty == TY::Tvoid);
 
                tree type = build_ctype (e->type);
diff --git a/gcc/testsuite/gdc.dg/pr123419.d b/gcc/testsuite/gdc.dg/pr123419.d
new file mode 100644 (file)
index 0000000..69ad444
--- /dev/null
@@ -0,0 +1,9 @@
+// { dg-do compile }
+struct S123419 {}
+
+void t123419(T)(T _) {}
+
+void f123419()
+{
+    t123419(__traits(initSymbol, S123419));
+}