This is the mail archive of the
fortran@gcc.gnu.org
mailing list for the GNU Fortran project.
Re: [fortran] spurious initialized warning with select-case?
- From: Steve Kargl <sgk at troutmask dot apl dot washington dot edu>
- To: Daniel Franke <franke dot daniel at gmail dot com>
- Cc: fortran at gcc dot gnu dot org, gcc at gcc dot gnu dot org
- Date: Sun, 5 Apr 2009 09:38:35 -0700
- Subject: Re: [fortran] spurious initialized warning with select-case?
- References: <200904051748.44878.franke.daniel@gmail.com>
On Sun, Apr 05, 2009 at 05:48:44PM +0200, Daniel Franke wrote:
> Hi all.
>
> Here's another spurious(?) uninitialized warning. As the full range is
> implied, the question is, if this a fortran or a middle-end problem:
>
> $> cat range.f90
> FUNCTION f(n)
> INTEGER, INTENT(in) :: n
> REAL :: f
>
> SELECT CASE (n)
> CASE ( :-1); f = -1.0
> CASE (0); f = 0.0
> CASE (1: ); f = 1.0
> END SELECT
> END FUNCTION
>
> $> gfortran-svn -c -O -Wall -fdump-tree-... range.f90
> range.f90: In function 'f':
> range.f90:1: warning: '__result_f' may be used uninitialized in this function
>
> After optimization, the dump shows:
> <bb 2>:
> switch (*n;) <default: <L6>, case -2147483648 ... -1: <L7>, case 0: L.3,
> case 1 ... 2147483647: L.4>
>
> Is there any way that 'default' may be reached?
> Any pointers how to silence this?
>
I'm not sure if it would work and I have idea where in trans*.c
you need to do this, but if you mark the tree as used with
something like
TREE_USED (__result_f) = 1
the middle-end may be silenced.
--
Steve