Bug 50334 - interaction between -Wuninitialized and -finit-*
Summary: interaction between -Wuninitialized and -finit-*
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: fortran (show other bugs)
Version: 4.6.1
: P5 enhancement
Target Milestone: 4.7.0
Assignee: Francois-Xavier Coudert
URL: http://gcc.gnu.org/ml/gcc-patches/201...
Keywords: documentation, patch
Depends on:
Blocks:
 
Reported: 2011-09-08 16:22 UTC by Arnaud Desitter
Modified: 2011-11-08 08:11 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2011-11-08 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Arnaud Desitter 2011-09-08 16:22:14 UTC
Considering
      subroutine qq(aa)
      aa = bb + 1 ! bb unset
      end subroutine

>gfortran461 -O3 -Wuninitialized -c qq.f
qq.f: In function 'qq':
qq.f:2:0: warning: 'bb' is used uninitialized in this function [-Wuninitialized]
>gfortran461 -O3 -Wuninitialized -finit-real=snan -c qq.f
>

The absence of compile-time warnings in the second case surprised me for a while until I tracked it down to "-finit-real=snan". "-finit-real=snan" is a killer feature of gfortran, badly missing in Intel Fortran for instance. It is somewhat regrettable that this option disables the compile-time warnings about uninitialized variables as "snan" in this case is used to find unset variables at run-time.

Could you at least add a note in the description of "-finit-real=" explaining that "-finit-real=" will disable the warnings about uninitialized variables even for "snan"?
Comment 1 Andrew Pinski 2011-09-08 16:40:19 UTC
Well this is kinda of expected, since you are saying all float variables are going to be initialized with SNAN so you can detect at runtime those variables which were left uninitialized.
Comment 2 kargls 2011-09-08 17:05:37 UTC
Changed to enhancement request.

Although, I think that this should be closed as
a 'Doctor, it hurts when I do this.' issue.
Comment 3 Francois-Xavier Coudert 2011-11-08 07:56:41 UTC
Document patch submitted at http://gcc.gnu.org/ml/gcc-patches/2011-11/msg01136.html
Comment 4 Francois-Xavier Coudert 2011-11-08 08:11:16 UTC
Author: fxcoudert
Date: Tue Nov  8 08:11:10 2011
New Revision: 181150

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=181150
Log:
	PR fortran/50334
	* invoke.texi (-finit-*): Document interaction with
	-Wuninitialized.

Modified:
    trunk/gcc/fortran/ChangeLog
    trunk/gcc/fortran/invoke.texi
Comment 5 Francois-Xavier Coudert 2011-11-08 08:11:57 UTC
Fixed on trunk.