]> git.ipfire.org Git - thirdparty/gcc.git/commit
middle-end/115641 - invalid address construction
authorRichard Biener <rguenther@suse.de>
Thu, 18 Jul 2024 11:35:33 +0000 (13:35 +0200)
committerRichard Biener <rguenth@gcc.gnu.org>
Thu, 18 Jul 2024 12:53:31 +0000 (14:53 +0200)
commit3670c70c561656a19f6bff36dd229f18120af127
tree993c6a499893fc9540627b724a58e514109ae31e
parentebac11afbcb7a52536da5f04fc524b870f5d76e0
middle-end/115641 - invalid address construction

fold_truth_andor_1 via make_bit_field_ref builds an address of
a CALL_EXPR which isn't valid GENERIC and later causes an ICE.
The following simply avoids the folding for f ().a != 1 || f ().b != 2
as it is a premature optimization anyway.  The alternative would
have been to build a TARGET_EXPR around the call.  To get this far
f () has to be const as otherwise the two calls are not semantically
equivalent for the optimization.

PR middle-end/115641
* fold-const.cc (decode_field_reference): If the inner
reference isn't something we can take the address of, fail.

* gcc.dg/torture/pr115641.c: New testcase.
gcc/fold-const.cc
gcc/testsuite/gcc.dg/torture/pr115641.c [new file with mode: 0644]