https://gcc.gnu.org/g:9da809aa4caa4f369094b1b0818c9919bf1e95e7

commit r13-10061-g9da809aa4caa4f369094b1b0818c9919bf1e95e7
Author: Iain Buclaw <[email protected]>
Date:   Wed Jan 28 23:06:23 2026 +0100

    d: Fix ICE in ExprVisitor::visit, at d/expr.cc:2224 [PR123419]
    
    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.
    
    (cherry picked from commit ddf94524f9accb47c1fc59191739ec34c5907eb8)

Diff:
---
 gcc/d/expr.cc                   | 3 ++-
 gcc/testsuite/gdc.dg/pr123419.d | 9 +++++++++
 2 files changed, 11 insertions(+), 1 deletion(-)

diff --git a/gcc/d/expr.cc b/gcc/d/expr.cc
index 653f42a9568f..eaa56812d822 100644
--- a/gcc/d/expr.cc
+++ b/gcc/d/expr.cc
@@ -2193,7 +2193,8 @@ public:
              {
                /* Generate a slice for non-zero initialized aggregates,
                   otherwise create an empty array.  */
-               gcc_assert (e->type == Type::tvoid->arrayOf ()->constOf ());
+               gcc_assert (e->type->nextOf ()->isConst ()
+                           && e->type->nextOf ()->ty == TY::Tvoid);
 
                tree type = build_ctype (e->type);
                tree length = size_int (sd->dsym->structsize);
diff --git a/gcc/testsuite/gdc.dg/pr123419.d b/gcc/testsuite/gdc.dg/pr123419.d
new file mode 100644
index 000000000000..69ad444deb8b
--- /dev/null
+++ b/gcc/testsuite/gdc.dg/pr123419.d
@@ -0,0 +1,9 @@
+// { dg-do compile }
+struct S123419 {}
+
+void t123419(T)(T _) {}
+
+void f123419()
+{
+    t123419(__traits(initSymbol, S123419));
+}

Reply via email to