https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111873
--- Comment #8 from Eric Botcazou <ebotcazou at gcc dot gnu.org> --- The bug is in the (early) SRA pass though; void h (const struct a i) { const short int i$b; int _1; short int _2; int _3; short int _4; int _5; <bb 2> : i$b_10 = i.b; i.b = i$b_10; _1 = g (i); d = _1; _2 = i$b_10; _3 = (int) _2; f (_3); _4 = i$b_10; _5 = (int) _4; e (_5); return; } which creates a store to the read-only parameter i: (gdb) p debug_gimple_stmt(stmt) # .MEM = VDEF <.MEM> i.b = i$b; $2 = void (gdb) p debug_tree(gimple_get_lhs (stmt)) <component_ref 0x7ffff71dee10 type <integer_type 0x7ffff71b6930 short int readonly sizes-gimplified HI size <integer_cst 0x7ffff702c0f0 constant 16> unit-size <integer_cst 0x7ffff702c108 constant 2> align:16 warn_if_not_align:0 symtab:0 alias-set -1 canonical-type 0x7ffff71b6930 precision:16 min <integer_cst 0x7ffff702c090 -32768> max <integer_cst 0x7ffff702c0c0 32767>> readonly arg:0 <parm_decl 0x7ffff7fc8300 i type <record_type 0x7ffff71b6540 a readonly sizes-gimplified type_0 HI size <integer_cst 0x7ffff702c0f0 16> unit-size <integer_cst 0x7ffff702c108 2> align:16 warn_if_not_align:0 symtab:0 alias-set -1 canonical-type 0x7ffff71b6540 fields <field_decl 0x7ffff7039688 b>> readonly used read HI pr111873.c:18:24 size <integer_cst 0x7ffff702c0f0 16> unit-size <integer_cst 0x7ffff702c108 2> align:16 warn_if_not_align:0 context <function_decl 0x7ffff71e2300 h> arg-type <record_type 0x7ffff71b6540 a>> arg:1 <field_decl 0x7ffff7039688 b type <integer_type 0x7ffff702a498 short int sizes-gimplified HI size <integer_cst 0x7ffff702c0f0 16> unit-size <integer_cst 0x7ffff702c108 2> align:16 warn_if_not_align:0 symtab:0 alias-set -1 canonical-type 0x7ffff702a498 precision:16 min <integer_cst 0x7ffff702c090 -32768> max <integer_cst 0x7ffff702c0c0 32767>> HI pr111873.c:5:9 size <integer_cst 0x7ffff702c0f0 16> unit-size <integer_cst 0x7ffff702c108 2> align:16 warn_if_not_align:0 offset_align 128 decl_not_flexarray: 1 offset <integer_cst 0x7ffff700bf60 constant 0> bit-offset <integer_cst 0x7ffff700bfa8 constant 0> context <record_type 0x7ffff71b6f18 a>> pr111873.c:21:7 start: pr111873.c:21:6 finish: pr111873.c:21:8> /* In a VAR_DECL, PARM_DECL or FIELD_DECL, or any kind of ..._REF node, nonzero means it may not be the lhs of an assignment. Nonzero in a FUNCTION_DECL means this function should be treated as "const" function (can only read its arguments). */ #define TREE_READONLY(NODE) (NON_TYPE_CHECK (NODE)->base.readonly_flag)