* Warning not catched
@ 2017-09-17 10:20 Angelo Graziosi
2017-09-17 10:37 ` Janus Weil
2017-09-17 14:25 ` Thomas Koenig
0 siblings, 2 replies; 5+ messages in thread
From: Angelo Graziosi @ 2017-09-17 10:20 UTC (permalink / raw)
To: fortran
Consider this simple test case:
program test_warn
implicit none
integer, parameter :: DP = selected_real_kind(12,60)
real(DP), parameter :: Z0 = 0
integer :: b(5)
b(1:5) = Z0
end program test_warn
and compile it with:
gfortran -Wall -O2 -c test_warn.f90
Now, only with gcc version 5.4.0 20160609 (Ubuntu 5.4.0-6ubuntu1~16.04.4) it prints the warning:
test_warn.f90:9:11:
b(1:5) = Z0
1
Warning: Possible change of value in conversion from REAL(8) to INTEGER(4) at (1) [-Wconversion]
Instead the following more recent versions of gfortran do NOT emit any warning:
1) (on MSYS2, msys2 shell)
Target: x86_64-pc-msys
gcc version 6.3.0 (GCC)
2) (on MSYS2, mingw32 shell)
Target: i686-w64-mingw32
gcc version 7.2.0 (Rev1, Built by MSYS2 project)
3) (on MSYS2, mingw64 shell)
Target: x86_64-w64-mingw32
gcc version 7.2.0 (Rev1, Built by MSYS2 project)
4) (Win10 - Windows Subsystem for Linux)
Target: x86_64-pc-linux-gnu
gcc version 7.1.0 (GCC)
5) (on macOS 10.12 + MacPorts)
Target: x86_64-apple-darwin16
gcc version 6.4.0 (MacPorts gcc6 6.4.0_0)
(all Thread model: posix).
Is this to be expected? (My mind says no..)
Thanks,
Angelo.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Warning not catched
2017-09-17 10:20 Warning not catched Angelo Graziosi
@ 2017-09-17 10:37 ` Janus Weil
2017-09-17 10:44 ` Angelo Graziosi
2017-09-17 14:25 ` Thomas Koenig
1 sibling, 1 reply; 5+ messages in thread
From: Janus Weil @ 2017-09-17 10:37 UTC (permalink / raw)
To: Angelo Graziosi; +Cc: gfortran
Hi Angelo,
> Consider this simple test case:
>
> program test_warn
> implicit none
>
> integer, parameter :: DP = selected_real_kind(12,60)
> real(DP), parameter :: Z0 = 0
>
> integer :: b(5)
>
> b(1:5) = Z0
> end program test_warn
>
> and compile it with:
>
> gfortran -Wall -O2 -c test_warn.f90
>
> Now, only with gcc version 5.4.0 20160609 (Ubuntu 5.4.0-6ubuntu1~16.04.4) it prints the warning:
>
> test_warn.f90:9:11:
> b(1:5) = Z0
> 1
> Warning: Possible change of value in conversion from REAL(8) to INTEGER(4) at (1) [-Wconversion]
>
> Instead the following more recent versions of gfortran do NOT emit any warning:
>
> [...]
>
> Is this to be expected? (My mind says no..)
This is PR 82018, for which I submitted a patch just yesterday (see
https://gcc.gnu.org/ml/fortran/2017-09/msg00046.html).
Removing this warning from -Wall was a conscious decision apparently.
My patch adds it to -Wextra at least.
Since there was quite a bit of discussion about this, maybe you can
give us your opinion as a gfortran user: Is this warning useful to
you? Do you think it's suitable for -Wall? Is it sufficient to have it
in -Wextra? (If other users reading this list have an opinion on this
matter, I'd like to hear that as well).
Cheers,
Janus
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Warning not catched
2017-09-17 10:37 ` Janus Weil
@ 2017-09-17 10:44 ` Angelo Graziosi
0 siblings, 0 replies; 5+ messages in thread
From: Angelo Graziosi @ 2017-09-17 10:44 UTC (permalink / raw)
To: Janus Weil; +Cc: gfortran
Ciao Janus,
> Il 17 settembre 2017 alle 12.37 Janus Weil <janus@gcc.gnu.org> ha scritto:
>
> [...]
> Since there was quite a bit of discussion about this, maybe you can
> give us your opinion as a gfortran user: Is this warning useful to
> you? Do you think it's suitable for -Wall? Is it sufficient to have it
> in -Wextra? (If other users reading this list have an opinion on this
> matter, I'd like to hear that as well).
I think it is useful in -Wall. In any case it should be at least in -Wextra. Thanks.
Ciao,
Angelo
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Warning not catched
2017-09-17 10:20 Warning not catched Angelo Graziosi
2017-09-17 10:37 ` Janus Weil
@ 2017-09-17 14:25 ` Thomas Koenig
2017-09-17 20:11 ` Angelo Graziosi
1 sibling, 1 reply; 5+ messages in thread
From: Thomas Koenig @ 2017-09-17 14:25 UTC (permalink / raw)
To: Angelo Graziosi, fortran
Hi Angelo,
> program test_warn
> implicit none
>
> integer, parameter :: DP = selected_real_kind(12,60)
> real(DP), parameter :: Z0 = 0
>
> integer :: b(5)
>
> b(1:5) = Z0
> end program test_warn
>
> and compile it with:
>
> gfortran -Wall -O2 -c test_warn.f90
>
> Now, only with gcc version 5.4.0 20160609 (Ubuntu 5.4.0-6ubuntu1~16.04.4) it prints the warning:
>
> test_warn.f90:9:11:
> b(1:5) = Z0
> 1
> Warning: Possible change of value in conversion from REAL(8) to INTEGER(4) at (1) [-Wconversion]
>
> Instead the following more recent versions of gfortran do NOT emit any warning:
There is no change of value in conversion; the compiler has gotten
smart enough to detect this in the meantime.
Consider this, by comparison:
program test_warn
implicit none
integer, parameter :: DP = selected_real_kind(12,60)
real(DP), parameter :: Z0 = 1.2_DP
integer :: b(5)
b(1:5) = Z0
end program test_warn
$ !gf
gfortran -Wall a.f90
a.f90:6:11:
b(1:5) = Z0
1
Warning: Change of value in conversion from 'REAL(8)' to 'INTEGER(4)' at
(1) [-Wconversion]
The reason was to remove clutter from -Wall.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Warning not catched
2017-09-17 14:25 ` Thomas Koenig
@ 2017-09-17 20:11 ` Angelo Graziosi
0 siblings, 0 replies; 5+ messages in thread
From: Angelo Graziosi @ 2017-09-17 20:11 UTC (permalink / raw)
To: Thomas Koenig, fortran
Ciao Thomas
> Il 17 settembre 2017 alle 16.24 Thomas Koenig <tkoenig@netcologne.de> ha scritto:
> There is no change of value in conversion; the compiler has gotten
> smart enough to detect this in the meantime.
>
> Consider this, by comparison:
>
> program test_warn
> implicit none
> integer, parameter :: DP = selected_real_kind(12,60)
> real(DP), parameter :: Z0 = 1.2_DP
> integer :: b(5)
> b(1:5) = Z0
> end program test_warn
> $ !gf
> gfortran -Wall a.f90
> a.f90:6:11:
>
> b(1:5) = Z0
> 1
> Warning: Change of value in conversion from 'REAL(8)' to 'INTEGER(4)' at
> (1) [-Wconversion]
>
I verified that playing with the test case.. Maybe my preference for that is only matter of style, a sort of coherence using the same type to initialize a variable... Maybe -Wextra is enough. Thanks for clarification.
Angelo
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2017-09-17 20:11 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-09-17 10:20 Warning not catched Angelo Graziosi
2017-09-17 10:37 ` Janus Weil
2017-09-17 10:44 ` Angelo Graziosi
2017-09-17 14:25 ` Thomas Koenig
2017-09-17 20:11 ` Angelo Graziosi
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).