This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug middle-end/85599] Prevent short-circuiting of logical expressions for non-pure functions


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?

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]