public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "burnus at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug fortran/57160] short-circuit IF only with -ffrontend-optimize Date: Sat, 04 May 2013 19:23:00 -0000 [thread overview] Message-ID: <bug-57160-4-4naHShIvVk@http.gcc.gnu.org/bugzilla/> (raw) In-Reply-To: <bug-57160-4@http.gcc.gnu.org/bugzilla/> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57160 Tobias Burnus <burnus at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |burnus at gcc dot gnu.org --- Comment #1 from Tobias Burnus <burnus at gcc dot gnu.org> 2013-05-04 19:23:08 UTC --- 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. Hence, the middle end/target-code generation might decide to evaluate "A.AND.B" as "A andif B", "B andif A" or both as "A and B". That's really outside the scope of the Fortran front end. What you would like is that both A and B are /always/ evaluated with .AND. That's quite some work with little gain. As I know for experience, the current TRUTH_AND_EXPR does no short-circuit evaluation in the given order - I already had segfaults for code similar to your's. * * * As a side note, see http://www.j3-fortran.org/doc/year/13/13-234.txt for a proposal for the next Fortran standard which allows to explicitly require short-circuit evaluation, using: if ( IF (ASSOCIATED(m)) THEN (m%T) ELSE (.false.) ) then write (6,*) s1(m) end if Or even as: write (6,*) IF (ASSOCIATED(m)) THEN ( IF(m%T)then("X")ELSE("") ) ELSE ("")
next prev parent reply other threads:[~2013-05-04 19:23 UTC|newest] Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top 2013-05-03 12:41 [Bug fortran/57160] New: " Joost.VandeVondele at mat dot ethz.ch 2013-05-04 19:23 ` burnus at gcc dot gnu.org [this message] 2013-07-21 21:08 ` [Bug fortran/57160] " tkoenig at gcc dot gnu.org 2014-12-21 15:18 ` dominiq at lps dot ens.fr 2014-12-22 7:12 ` Joost.VandeVondele at mat dot ethz.ch
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=bug-57160-4-4naHShIvVk@http.gcc.gnu.org/bugzilla/ \ --to=gcc-bugzilla@gcc.gnu.org \ --cc=gcc-bugs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).