This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug middle-end/85599] Prevent short-circuiting of logical expressions for non-pure functions
- From: "janus at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Thu, 17 May 2018 07:11:35 +0000
- Subject: [Bug middle-end/85599] Prevent short-circuiting of logical expressions for non-pure functions
- Auto-submitted: auto-generated
- References: <bug-85599-4@http.gcc.gnu.org/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85599
--- Comment #24 from janus at gcc dot gnu.org ---
(In reply to Andrew Pinski from comment #22)
> the semantics of TRUTH_ANDIF_EXPR is always to short circuit.
> If you want a non short circuit you need to use TRUTH_AND_EXPR
I haven't looked at the actual code yet, but pr57160 comment 1 sounds like we
already use TRUTH_AND_EXPR:
> GCC (the middle end) has TRUTH_AND_EXPR (matching Fortran's .AND.) and
> TRUTH_ANDIF_EXPR (matching C's &&) - besides the IAND/& which is
> BIT_AND_EXPR.
>
> Currently, the code generation directly translates all .AND. into
> TRUTH_AND_EXPR.
If that's indeed the case, and TRUTH_AND_EXPR actually results in
short-circuiting, then I'm not sure I understand the difference to
TRUTH_ANDIF_EXPR.
Probably BIT_AND_EXPR can be used to fully prevent short-circuiting?