[gcc r16-7120] d: Fix ICE: in expand_asm_stmt, at cfgexpand.cc:3445 [PR121477]
Iain Buclaw
ibuclaw@gcc.gnu.org
Wed Jan 28 17:44:27 GMT 2026
https://gcc.gnu.org/g:baaa412ae73c12e2e5ea2552534ec42525f6d21e
commit r16-7120-gbaaa412ae73c12e2e5ea2552534ec42525f6d21e
Author: Iain Buclaw <ibuclaw@gdcproject.org>
Date: Wed Jan 28 18:34:21 2026 +0100
d: Fix ICE: in expand_asm_stmt, at cfgexpand.cc:3445 [PR121477]
The d_mark_addressable routine that sets TREE_ADDRESSABLE in the D
front-end did not handle DECL_BIT_FIELD.
PR d/121477
gcc/d/ChangeLog:
* d-codegen.cc (d_mark_addressable): Give an error if taking the
address of a DECL_BIT_FIELD.
gcc/testsuite/ChangeLog:
* gdc.dg/pr121477.d: New test.
Diff:
---
gcc/d/d-codegen.cc | 6 +++++-
gcc/testsuite/gdc.dg/pr121477.d | 12 ++++++++++++
2 files changed, 17 insertions(+), 1 deletion(-)
diff --git a/gcc/d/d-codegen.cc b/gcc/d/d-codegen.cc
index 716fa447eba1..9ec23546b4ad 100644
--- a/gcc/d/d-codegen.cc
+++ b/gcc/d/d-codegen.cc
@@ -745,8 +745,12 @@ d_mark_addressable (tree exp, bool complain)
{
switch (TREE_CODE (exp))
{
- case ADDR_EXPR:
case COMPONENT_REF:
+ if (complain && DECL_BIT_FIELD (TREE_OPERAND (exp, 1)))
+ error ("cannot take address of bit-field %qD", TREE_OPERAND (exp, 1));
+
+ /* Fall through. */
+ case ADDR_EXPR:
case ARRAY_REF:
case REALPART_EXPR:
case IMAGPART_EXPR:
diff --git a/gcc/testsuite/gdc.dg/pr121477.d b/gcc/testsuite/gdc.dg/pr121477.d
new file mode 100644
index 000000000000..3f5bc359272e
--- /dev/null
+++ b/gcc/testsuite/gdc.dg/pr121477.d
@@ -0,0 +1,12 @@
+// { dg-do compile }
+// { dg-additional-options "-fpreview=bitfields" }
+struct S121477
+{
+ int x : 4;
+}
+
+void f121477(S121477 s)
+{
+ asm {"%0" :: "m" (s.x); } // { dg-error "cannot take address of bit-field" }
+ asm {"%0" : "=m" (s.x); } // { dg-error "cannot take address of bit-field" }
+}
More information about the Gcc-cvs
mailing list