public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/54298] New: Add warning when doing equal/nonequal floating-point comparisons
@ 2012-08-17 15:15 burnus at gcc dot gnu.org
  2012-08-17 16:08 ` [Bug fortran/54298] " tkoenig at gcc dot gnu.org
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: burnus at gcc dot gnu.org @ 2012-08-17 15:15 UTC (permalink / raw)
  To: gcc-bugs

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

             Bug #: 54298
           Summary: Add warning when doing equal/nonequal floating-point
                    comparisons
    Classification: Unclassified
           Product: gcc
           Version: 4.8.0
            Status: UNCONFIRMED
          Keywords: diagnostic
          Severity: normal
          Priority: P3
         Component: fortran
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: burnus@gcc.gnu.org


Suggested by ISO/IEC Project 22.24772 "Guidance for Avoiding Vulnerabilities
through Language Selection and Use"  (see links at
http://gcc.gnu.org/wiki/GFortranStandards)

>From the Fortran appendix (draft at
http://grouper.ieee.org/groups/plv/DocLog/400-499/400-419/22-WG23-N-0410/n0410.pdf)


"Fortran.5 Floating-point Arithmetic [PFL]
...
"Fortran.5.2 Guidance to Fortran Users"
...
"* Do not create a logical value from a test for equality or inequality between
two floating-point expressions. Use compiler options where available to detect
such a usage"


gfortran doesn't have such a warning.


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug fortran/54298] Add warning when doing equal/nonequal floating-point comparisons
  2012-08-17 15:15 [Bug fortran/54298] New: Add warning when doing equal/nonequal floating-point comparisons burnus at gcc dot gnu.org
@ 2012-08-17 16:08 ` tkoenig at gcc dot gnu.org
  2012-08-17 16:24 ` burnus at gcc dot gnu.org
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: tkoenig at gcc dot gnu.org @ 2012-08-17 16:08 UTC (permalink / raw)
  To: gcc-bugs

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

Thomas Koenig <tkoenig at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |ASSIGNED
   Last reconfirmed|                            |2012-08-17
                 CC|                            |tkoenig at gcc dot gnu.org
         AssignedTo|unassigned at gcc dot       |tkoenig at gcc dot gnu.org
                   |gnu.org                     |
     Ever Confirmed|0                           |1

--- Comment #1 from Thomas Koenig <tkoenig at gcc dot gnu.org> 2012-08-17 16:07:43 UTC ---
Sounds doable.

I'll give it a shot.


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug fortran/54298] Add warning when doing equal/nonequal floating-point comparisons
  2012-08-17 15:15 [Bug fortran/54298] New: Add warning when doing equal/nonequal floating-point comparisons burnus at gcc dot gnu.org
  2012-08-17 16:08 ` [Bug fortran/54298] " tkoenig at gcc dot gnu.org
@ 2012-08-17 16:24 ` burnus at gcc dot gnu.org
  2012-08-19 15:06 ` tkoenig at gcc dot gnu.org
  2012-08-19 16:08 ` tkoenig at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: burnus at gcc dot gnu.org @ 2012-08-17 16:24 UTC (permalink / raw)
  To: gcc-bugs

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

Tobias Burnus <burnus at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |burnus at gcc dot gnu.org

--- Comment #2 from Tobias Burnus <burnus at gcc dot gnu.org> 2012-08-17 16:24:44 UTC ---
(In reply to comment #1)
> Sounds doable.
> I'll give it a shot.

Thanks. I think it can help to find some real-world issues, even if comparisons
such as "a == 0.0" are generally safe.

(In reply to comment #0)
> Suggested by ISO/IEC Project 22.24772 "Guidance for Avoiding Vulnerabilities
> through Language Selection and Use"  (see links at
> http://gcc.gnu.org/wiki/GFortranStandards)
> 
> From the Fortran appendix (draft at

Wrong link (that's the current 2nd-version draft of the TR, still the Fortran
part). The Fortran link is:
  ftp://ftp.nag.co.uk/sc22wg5/N1901-N1950/N1929.pdf


The issue is also mentioned in "Fortran.58 Implications for Standardization"
under "Future standardization efforts should consider:"

"Requiring that processors have the ability to detect and report the occurrence
within a submitted program unit of tests for equality between two objects of
type real or complex."


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug fortran/54298] Add warning when doing equal/nonequal floating-point comparisons
  2012-08-17 15:15 [Bug fortran/54298] New: Add warning when doing equal/nonequal floating-point comparisons burnus at gcc dot gnu.org
  2012-08-17 16:08 ` [Bug fortran/54298] " tkoenig at gcc dot gnu.org
  2012-08-17 16:24 ` burnus at gcc dot gnu.org
@ 2012-08-19 15:06 ` tkoenig at gcc dot gnu.org
  2012-08-19 16:08 ` tkoenig at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: tkoenig at gcc dot gnu.org @ 2012-08-19 15:06 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from Thomas Koenig <tkoenig at gcc dot gnu.org> 2012-08-19 15:05:49 UTC ---
Author: tkoenig
Date: Sun Aug 19 15:05:41 2012
New Revision: 190516

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=190516
Log:
2012-08-19  Thomas König  <tkoenig@gcc.gnu.org>

    PR fortran/54298
    * gfortran.h (struct gfc_option_t): Add warn_compare_reals.
    * lang.opt:  Add Wcompare-reals.
    * invoke.texi:  Document -Wcompare-reals.
    * resolve.c (resolve_operator):  If -Wcompare-reals is in effect,
    warn about equality/inequality comparisions for REAL and COMPLEX.
    * options.c (gfc_init_options):  Set warn_compare_reals.
    (set_Wall):  Include warn_compare_reals in Wall.
    (gfc_handle_option):  Handle Wcompare_reals.

2012-08-19  Thomas König  <tkoenig@gcc.gnu.org>

    PR fortran/54298
    * gfortran.dg/real_compare_1.f90:  New test case.
    * gfortran.dg/bessel_5.f90  Add -Wno-compare-reals to options.


Added:
    trunk/gcc/testsuite/gfortran.dg/real_compare_1.f90
Modified:
    trunk/gcc/fortran/ChangeLog
    trunk/gcc/fortran/gfortran.h
    trunk/gcc/fortran/invoke.texi
    trunk/gcc/fortran/lang.opt
    trunk/gcc/fortran/options.c
    trunk/gcc/fortran/resolve.c
    trunk/gcc/testsuite/ChangeLog
    trunk/gcc/testsuite/gfortran.dg/bessel_5.f90


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug fortran/54298] Add warning when doing equal/nonequal floating-point comparisons
  2012-08-17 15:15 [Bug fortran/54298] New: Add warning when doing equal/nonequal floating-point comparisons burnus at gcc dot gnu.org
                   ` (2 preceding siblings ...)
  2012-08-19 15:06 ` tkoenig at gcc dot gnu.org
@ 2012-08-19 16:08 ` tkoenig at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: tkoenig at gcc dot gnu.org @ 2012-08-19 16:08 UTC (permalink / raw)
  To: gcc-bugs

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

Thomas Koenig <tkoenig at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|                            |FIXED

--- Comment #4 from Thomas Koenig <tkoenig at gcc dot gnu.org> 2012-08-19 16:08:37 UTC ---
Fixed on trunk, closing.


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2012-08-19 16:08 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-08-17 15:15 [Bug fortran/54298] New: Add warning when doing equal/nonequal floating-point comparisons burnus at gcc dot gnu.org
2012-08-17 16:08 ` [Bug fortran/54298] " tkoenig at gcc dot gnu.org
2012-08-17 16:24 ` burnus at gcc dot gnu.org
2012-08-19 15:06 ` tkoenig at gcc dot gnu.org
2012-08-19 16:08 ` tkoenig at gcc dot gnu.org

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).