* [Bug fortran/27866] Warn when casting, e.g. assigning a double precision to a real
2006-06-01 18:49 [Bug fortran/27866] New: Warn when casting, e.g. assigning a double precision to a real tobias dot burnus at physik dot fu-berlin dot de
@ 2006-06-01 21:09 ` tkoenig at gcc dot gnu dot org
2006-06-07 19:56 ` tkoenig at gcc dot gnu dot org
` (8 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: tkoenig at gcc dot gnu dot org @ 2006-06-01 21:09 UTC (permalink / raw)
To: gcc-bugs
------- Comment #1 from tkoenig at gcc dot gnu dot org 2006-06-01 21:09 -------
(In reply to comment #0)
> In the following program there is clearly a problem with the "r = d"
> assignment. In most real programs such drastic case does not happen. However,
> simple precision loss or worse things may occure.
>
> gfortran -Wall should warn, but it does not deserve a default warning.
There is -Wconversion, but this also warns the wrong way around.
--
tkoenig at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |tkoenig at gcc dot gnu dot
| |org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=27866
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug fortran/27866] Warn when casting, e.g. assigning a double precision to a real
2006-06-01 18:49 [Bug fortran/27866] New: Warn when casting, e.g. assigning a double precision to a real tobias dot burnus at physik dot fu-berlin dot de
2006-06-01 21:09 ` [Bug fortran/27866] " tkoenig at gcc dot gnu dot org
@ 2006-06-07 19:56 ` tkoenig at gcc dot gnu dot org
2007-02-14 15:47 ` manu at gcc dot gnu dot org
` (7 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: tkoenig at gcc dot gnu dot org @ 2006-06-07 19:56 UTC (permalink / raw)
To: gcc-bugs
------- Comment #2 from tkoenig at gcc dot gnu dot org 2006-06-07 19:32 -------
Yes, this would be useful.
Confirmed as an enhancement.
--
tkoenig at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Severity|normal |enhancement
Status|UNCONFIRMED |NEW
Ever Confirmed|0 |1
Last reconfirmed|0000-00-00 00:00:00 |2006-06-07 19:32:09
date| |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=27866
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug fortran/27866] Warn when casting, e.g. assigning a double precision to a real
2006-06-01 18:49 [Bug fortran/27866] New: Warn when casting, e.g. assigning a double precision to a real tobias dot burnus at physik dot fu-berlin dot de
2006-06-01 21:09 ` [Bug fortran/27866] " tkoenig at gcc dot gnu dot org
2006-06-07 19:56 ` tkoenig at gcc dot gnu dot org
@ 2007-02-14 15:47 ` manu at gcc dot gnu dot org
2007-02-16 20:50 ` tkoenig at gcc dot gnu dot org
` (6 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: manu at gcc dot gnu dot org @ 2007-02-14 15:47 UTC (permalink / raw)
To: gcc-bugs
------- Comment #3 from manu at gcc dot gnu dot org 2007-02-14 15:47 -------
(In reply to comment #1)
> (In reply to comment #0)
> > In the following program there is clearly a problem with the "r = d"
> > assignment. In most real programs such drastic case does not happen. However,
> > simple precision loss or worse things may occure.
> >
> > gfortran -Wall should warn, but it does not deserve a default warning.
>
> There is -Wconversion, but this also warns the wrong way around.
There is a new -Wconversion implementation. Perhaps you could do the same for
fortran as I did for C/C++. Take a look at c-common.c (conversion_warnings). It
would be great if -Wconversion behaves the same way (more or less) in all
front-ends.
--
manu at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |manu at gcc dot gnu dot org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=27866
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug fortran/27866] Warn when casting, e.g. assigning a double precision to a real
2006-06-01 18:49 [Bug fortran/27866] New: Warn when casting, e.g. assigning a double precision to a real tobias dot burnus at physik dot fu-berlin dot de
` (2 preceding siblings ...)
2007-02-14 15:47 ` manu at gcc dot gnu dot org
@ 2007-02-16 20:50 ` tkoenig at gcc dot gnu dot org
2007-02-16 21:09 ` manu at gcc dot gnu dot org
` (5 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: tkoenig at gcc dot gnu dot org @ 2007-02-16 20:50 UTC (permalink / raw)
To: gcc-bugs
------- Comment #4 from tkoenig at gcc dot gnu dot org 2007-02-16 20:50 -------
(In reply to comment #3)
> There is a new -Wconversion implementation. Perhaps you could do the same for
> fortran as I did for C/C++. Take a look at c-common.c (conversion_warnings). It
> would be great if -Wconversion behaves the same way (more or less) in all
> front-ends.
This would be a good idea.
Looking at the code from c-common.c, we should warn about
real(kind=4) :: a
real(kind=8) :: b
integer(kind=1) :: i1
integer(kind=4) :: i4
i4 = 2.3 ! Not exact
i1 = 500 ! doesn't fit
a = 2**26-1 ! Loses bits of precision
b = 1d99 ! Doesn't fit the type
a = i4 ! may lose extra digits
b = i4 ! This is OK (enough digits in the kind=8 var)
i1 = i4 ! i1 may not be able to represent the values in i4
a = b ! precision loss
For Fortran, we should also warn about
b = 2.5
print *,b**(3/2) ! identical to b**1, usually unintended
and maybe even about
print *,4/3 ! constant integer division
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=27866
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug fortran/27866] Warn when casting, e.g. assigning a double precision to a real
2006-06-01 18:49 [Bug fortran/27866] New: Warn when casting, e.g. assigning a double precision to a real tobias dot burnus at physik dot fu-berlin dot de
` (3 preceding siblings ...)
2007-02-16 20:50 ` tkoenig at gcc dot gnu dot org
@ 2007-02-16 21:09 ` manu at gcc dot gnu dot org
2007-02-18 21:19 ` tkoenig at gcc dot gnu dot org
` (4 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: manu at gcc dot gnu dot org @ 2007-02-16 21:09 UTC (permalink / raw)
To: gcc-bugs
------- Comment #5 from manu at gcc dot gnu dot org 2007-02-16 21:08 -------
(In reply to comment #4)
> (In reply to comment #3)
>
> > There is a new -Wconversion implementation. Perhaps you could do the same for
> > fortran as I did for C/C++. Take a look at c-common.c (conversion_warnings). It
> > would be great if -Wconversion behaves the same way (more or less) in all
> > front-ends.
>
> This would be a good idea.
>
> Looking at the code from c-common.c, we should warn about
>
That is up to you. I don't know so much about fortran. I was just pointing to
the middle-end functions used in c-common.c to detect whether a value is
changed by the conversion. However, be careful about not warning in excess. For
example, constant integer division does not change any value, so I think it is
not appropriate for -Wconversion. But I guess that it is up to fortran
maintainers to make this decision.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=27866
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug fortran/27866] Warn when casting, e.g. assigning a double precision to a real
2006-06-01 18:49 [Bug fortran/27866] New: Warn when casting, e.g. assigning a double precision to a real tobias dot burnus at physik dot fu-berlin dot de
` (4 preceding siblings ...)
2007-02-16 21:09 ` manu at gcc dot gnu dot org
@ 2007-02-18 21:19 ` tkoenig at gcc dot gnu dot org
2007-04-19 20:45 ` pinskia at gcc dot gnu dot org
` (3 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: tkoenig at gcc dot gnu dot org @ 2007-02-18 21:19 UTC (permalink / raw)
To: gcc-bugs
------- Comment #6 from tkoenig at gcc dot gnu dot org 2007-02-18 21:18 -------
*** Bug 28399 has been marked as a duplicate of this bug. ***
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=27866
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug fortran/27866] Warn when casting, e.g. assigning a double precision to a real
2006-06-01 18:49 [Bug fortran/27866] New: Warn when casting, e.g. assigning a double precision to a real tobias dot burnus at physik dot fu-berlin dot de
` (5 preceding siblings ...)
2007-02-18 21:19 ` tkoenig at gcc dot gnu dot org
@ 2007-04-19 20:45 ` pinskia at gcc dot gnu dot org
2008-04-17 22:01 ` tkoenig at gcc dot gnu dot org
` (2 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2007-04-19 20:45 UTC (permalink / raw)
To: gcc-bugs
------- Comment #7 from pinskia at gcc dot gnu dot org 2007-04-19 21:45 -------
*** Bug 31637 has been marked as a duplicate of this bug. ***
--
pinskia at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |vivekrao4 at yahoo dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=27866
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug fortran/27866] Warn when casting, e.g. assigning a double precision to a real
2006-06-01 18:49 [Bug fortran/27866] New: Warn when casting, e.g. assigning a double precision to a real tobias dot burnus at physik dot fu-berlin dot de
` (6 preceding siblings ...)
2007-04-19 20:45 ` pinskia at gcc dot gnu dot org
@ 2008-04-17 22:01 ` tkoenig at gcc dot gnu dot org
2010-05-10 17:12 ` dfranke at gcc dot gnu dot org
2010-05-10 19:30 ` dfranke at gcc dot gnu dot org
9 siblings, 0 replies; 11+ messages in thread
From: tkoenig at gcc dot gnu dot org @ 2008-04-17 22:01 UTC (permalink / raw)
To: gcc-bugs
------- Comment #8 from tkoenig at gcc dot gnu dot org 2008-04-17 22:00 -------
*** Bug 35962 has been marked as a duplicate of this bug. ***
--
tkoenig at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |J dot Hogg at rl dot ac dot
| |uk
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=27866
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug fortran/27866] Warn when casting, e.g. assigning a double precision to a real
2006-06-01 18:49 [Bug fortran/27866] New: Warn when casting, e.g. assigning a double precision to a real tobias dot burnus at physik dot fu-berlin dot de
` (7 preceding siblings ...)
2008-04-17 22:01 ` tkoenig at gcc dot gnu dot org
@ 2010-05-10 17:12 ` dfranke at gcc dot gnu dot org
2010-05-10 19:30 ` dfranke at gcc dot gnu dot org
9 siblings, 0 replies; 11+ messages in thread
From: dfranke at gcc dot gnu dot org @ 2010-05-10 17:12 UTC (permalink / raw)
To: gcc-bugs
------- Comment #9 from dfranke at gcc dot gnu dot org 2010-05-10 17:11 -------
Subject: Bug 27866
Author: dfranke
Date: Mon May 10 17:10:53 2010
New Revision: 159238
URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=159238
Log:
gcc/fortran/:
2010-05-10 Daniel Franke <franke.daniel@gmail.com>
PR fortran/27866
PR fortran/35003
PR fortran/42809
* intrinsic.c (gfc_convert_type_warn): Be more discriminative
about conversion warnings.
gcc/testsuite/:
2010-05-08 Daniel Franke <franke.daniel@gmail.com>
PR fortran/27866
PR fortran/35003
PR fortran/42809
* gfortran.dg/array_constructor_type_17.f03: Updated match string.
* gfortran.dg/warn_conversion.f90: New.
Added:
trunk/gcc/testsuite/gfortran.dg/warn_conversion.f90
Modified:
trunk/gcc/fortran/ChangeLog
trunk/gcc/fortran/intrinsic.c
trunk/gcc/testsuite/ChangeLog
trunk/gcc/testsuite/gfortran.dg/array_constructor_type_17.f03
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=27866
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug fortran/27866] Warn when casting, e.g. assigning a double precision to a real
2006-06-01 18:49 [Bug fortran/27866] New: Warn when casting, e.g. assigning a double precision to a real tobias dot burnus at physik dot fu-berlin dot de
` (8 preceding siblings ...)
2010-05-10 17:12 ` dfranke at gcc dot gnu dot org
@ 2010-05-10 19:30 ` dfranke at gcc dot gnu dot org
9 siblings, 0 replies; 11+ messages in thread
From: dfranke at gcc dot gnu dot org @ 2010-05-10 19:30 UTC (permalink / raw)
To: gcc-bugs
------- Comment #10 from dfranke at gcc dot gnu dot org 2010-05-10 19:29 -------
We should now have about the same behaviour as with C.
The additional requests in comment #4 (integer division) are not handled by the
patch in #9. These are special cases and not necessarily related to
-Wconversion. Please open another PR if this should be pursued.
Closing as fixed.
--
dfranke at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
Resolution| |FIXED
Target Milestone|--- |4.6.0
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=27866
^ permalink raw reply [flat|nested] 11+ messages in thread