Spurious warnings in gfortran
Description
Various compilation warnings. eg "n may be used unitialized in this function". The code should be edited so that zero warnings are produced. with the -Wall flag on.
Warning: ‘n’ may be used uninitialized in this function [-Wmaybe-uninitialized]
/home/ian/fortran-stdlib/src/stdlib_stats_var.f90:4258:0:
4258 | real(sp) :: n
|
Warning: ‘n’ may be used uninitialized in this function [-Wmaybe-uninitialized]
/home/ian/fortran-stdlib/src/stdlib_stats_var.f90:4099:0:
4099 | real(qp) :: n
|
Warning: ‘n’ may be used uninitialized in this function [-Wmaybe-uninitialized]
/home/ian/fortran-stdlib/src/stdlib_stats_var.f90:3940:0:
3940 | real(xdp) :: n
|
Warning: ‘n’ may be used uninitialized in this function [-Wmaybe-uninitialized]
/home/ian/fortran-stdlib/src/stdlib_stats_var.f90:3781:0:
3781 | real(dp) :: n
|
Warning: ‘n’ may be used uninitialized in this function [-Wmaybe-uninitialized]
/home/ian/fortran-stdlib/src/stdlib_stats_var.f90:3622:0:
3622 | real(sp) :: n
|
Warning: ‘n’ may be used uninitialized in this function [-Wmaybe-uninitialized]
/home/ian/fortran-stdlib/src/stdlib_stats_var.f90:2815:0:
2815 | real(dp) :: n
|
Warning: ‘n’ may be used uninitialized in this function [-Wmaybe-uninitialized]
/home/ian/fortran-stdlib/src/stdlib_stats_var.f90:2772:0:
Expected Behaviour
A make run in which Warning messages are absent when running -Wall.
Version of stdlib
Fork 88
Platform and Architecture
Linux ubuntu
Additional Information
https://dl.acm.org/doi/abs/10.1145/763984.763986
Can the code for stdlib_stats_var.f90 be posted? My experience is that may be used uninitialized warnings from gfortran are often spurious. Maybe the the default build should disable this class of gfortran warnings.
The file stdlib_stats_var.f90 generated for fpm` can be found here.
These are indeed spurious warnings (at least the last time I checked).
Spurious gfortran warnings reported to bugzilla. ttps:// www.google.com/search?client=ms-google-coop&q=gfortran+spurious+warnings&cx=008043952663535741821:9whwb87ip5a
Did you mean: gfortran suppress warnings
70312 – Spurious -Wsurprising warnings for final subroutines https://gcc.gnu.org › bugzilla › show_bug 19 Mar 2016 — -Wsurprising issues spurious warnings about final procedures. module foo_type type foo contains final :: foo_delete end type contains ... You visited this page on 29/11/21.
59107 – [8/9/10/11 Regression] Spurious "Type specified for ...
https://gcc.gnu.org › bugzilla › show_bug
11 May 2020 — ... Apr 23 10:33:14 2020 +0100 Fortran : Spurious warning message with -Wsurprising PR59107 This change is from a patch developed for gcc-5.
[5/6 Regression] Spurious warning on derived type initialization https://gcc.gnu.org › bugzilla › show_bug 29 Sept 2019 — Bug 60500 - [5/6 Regression] Spurious warning on derived type ... compiler version: GNU Fortran (Ubuntu 4.8.1-2ubuntu1~12.04) 4.8.1 Notes: ...
Using the GNU Compiler Collection - GCC, the GNU Compiler ... https://gcc.gnu.org › onlinedocs › gcc-7.2.0 › gcc.ps.gz PS See Section “Standards” in The GNU Fortran Compiler, for details of standards ... Some spurious warnings can be avoided if you declare all the functions you.
On Mon, Nov 29, 2021 at 2:25 AM Jeremie Vandenplas @.***> wrote:
The file stdlib_stats_var.f90 generated for fpm` can be found here https://github.com/fortran-lang/stdlib/blob/stdlib-fpm/src/stdlib_stats_var.f90 .
These are indeed spurious warnings (at least the last time I checked).
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/fortran-lang/stdlib/issues/577#issuecomment-981103964, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABGRK522UF527S4WRISIETDUOJCXTANCNFSM5IXS2E5Q .
Such spurious warnings are an old bug in gfortran and they are not related to stdlib. This issue seems to come back and forth due to its nature. The most recent bugs I could track are:
Bug 77504 - [9/10/11/12/13 Regression] "is used uninitialized" with allocatable string and array constructors
Bug 56670 - Allocatable-length character var causes bogus warning with -Wuninitialized
It can't be fixed here (Only a patch to GCC could), so I guess this is a "won't fix". I'm editing the title so this issue gets shorter and clearer.
I'll keep this open in case someone is interested in proposing a workaround.