[Bug fortran/27866] Warn when casting, e.g. assigning a double precision to a real
--- 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
[Bug fortran/27866] Warn when casting, e.g. assigning a double precision to a real
--- 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 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 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
[Bug fortran/27866] Warn when casting, e.g. assigning a double precision to a real
--- 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
[Bug fortran/27866] Warn when casting, e.g. assigning a double precision to a real
--- 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
[Bug fortran/27866] Warn when casting, e.g. assigning a double precision to a real
--- 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
[Bug fortran/27866] Warn when casting, e.g. assigning a double precision to a real
--- 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
[Bug fortran/27866] Warn when casting, e.g. assigning a double precision to a real
--- 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
[Bug fortran/27866] Warn when casting, e.g. assigning a double precision to a real
--- 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
[Bug fortran/27866] Warn when casting, e.g. assigning a double precision to a real
--- 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|-00-00 00:00:00 |2006-06-07 19:32:09 date|| http://gcc.gnu.org/bugzilla/show_bug.cgi?id=27866
[Bug fortran/27866] Warn when casting, e.g. assigning a double precision to a real
--- 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