public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "furue at hawaii dot edu" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug fortran/57628] spurious error: division by zero in if statement
Date: Mon, 17 Jun 2013 21:42:00 -0000	[thread overview]
Message-ID: <bug-57628-4-Kdqgd94Aka@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-57628-4@http.gcc.gnu.org/bugzilla/>

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57628

--- Comment #15 from Ryo Furue <furue at hawaii dot edu> ---
(In reply to Harald Anlauf from comment #13)

Hi Harald,

Thanks for your message.

> I would also prefer if gfortran behaved as you suggested.
> Other compilers appear to generate warnings only, or no comment.
> After all, the code path in question never gets executed.
> 
> I am afraid that the Fortran standard document does not give
> much help here and may allow gfortran's behavior. 

I'm pretty sure that the Fortran standard allows gfortran's behavior.  I'm not
arguing that it's a violation of the standard.  I'm just asking for an option
to change the behavior (which would also within the standard).

The question is what is the best way to deal with illegal bits of code.  There,
there are a number of choices all within the standard.  For example, with this

  program try
    real:: a(10) = 1.0/0.0
    write(10) a
  end program try

the compiler is allowed to do anything and there is no single answer as to
what's best.  In some circumstances, to stop compiling with an error message is
the best way (gfortran's default behavior); in some circumstances, to replace
the constant expression with the IEEE +Infinity value and let the code pass
(-fno-range-check) is a better choice.  I certainly would write such a code as
the above to get a binary array of Infinities. (It's a quick-n-dirty way but it
works in practice.)

In other circumstances, the compiler can send en email message to the writer of
such a code, pointing out the stupidity of it :-)

Cheers,
Ryo


  parent reply	other threads:[~2013-06-17 21:42 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-06-16  6:39 [Bug fortran/57628] New: " furue at hawaii dot edu
2013-06-16  7:22 ` [Bug fortran/57628] " kargl at gcc dot gnu.org
2013-06-16  7:57 ` furue at hawaii dot edu
2013-06-16  8:13 ` furue at hawaii dot edu
2013-06-16  8:26 ` pinskia at gcc dot gnu.org
2013-06-16  8:47 ` furue at hawaii dot edu
2013-06-16  8:50 ` furue at hawaii dot edu
2013-06-16 14:34 ` dominiq at lps dot ens.fr
2013-06-16 14:55 ` sgk at troutmask dot apl.washington.edu
2013-06-16 23:28 ` furue at hawaii dot edu
2013-06-16 23:33 ` furue at hawaii dot edu
2013-06-17  5:00 ` sgk at troutmask dot apl.washington.edu
2013-06-17  5:00 ` sgk at troutmask dot apl.washington.edu
2013-06-17 18:54 ` anlauf at gmx dot de
2013-06-17 21:25 ` furue at hawaii dot edu
2013-06-17 21:42 ` furue at hawaii dot edu [this message]
2013-06-18  1:47 ` furue at hawaii dot edu
2013-06-18  1:56 ` furue at hawaii dot edu

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-57628-4-Kdqgd94Aka@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: link
Be 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).