[Bug fortran/20520] allocatable arrays used uninitialized without a warning

2018-10-31 Thread tkoenig at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=20520

Thomas Koenig  changed:

   What|Removed |Added

 Status|NEW |RESOLVED
 Resolution|--- |FIXED

--- Comment #21 from Thomas Koenig  ---
Marking as fixed.

[Bug fortran/20520] allocatable arrays used uninitialized without a warning

2018-10-31 Thread tkoenig at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=20520

--- Comment #20 from Thomas Koenig  ---
Author: tkoenig
Date: Wed Oct 31 18:35:59 2018
New Revision: 265698

URL: https://gcc.gnu.org/viewcvs?rev=265698=gcc=rev
Log:
2018-10-31  Thomas Koenig  

PR fortran/20520
* gfortran.dg/allocatable_uninitialized_1.f90: New test.


Added:
trunk/gcc/testsuite/gfortran.dg/allocatable_uninitialized_1.f90
Modified:
trunk/gcc/testsuite/ChangeLog

[Bug fortran/20520] allocatable arrays used uninitialized without a warning

2018-01-01 Thread dominiq at lps dot ens.fr
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=20520

Dominique d'Humieres  changed:

   What|Removed |Added

 CC||dominiq at lps dot ens.fr

--- Comment #19 from Dominique d'Humieres  ---
*** Bug 46182 has been marked as a duplicate of this bug. ***

[Bug fortran/20520] allocatable arrays used uninitialized without a warning

2018-01-01 Thread dominiq at lps dot ens.fr
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=20520

Dominique d'Humieres  changed:

   What|Removed |Added

 CC||ondrej.certik at gmail dot com

--- Comment #18 from Dominique d'Humieres  ---
*** Bug 64229 has been marked as a duplicate of this bug. ***

[Bug fortran/20520] allocatable arrays used uninitialized without a warning

2017-12-26 Thread tkoenig at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=20520

Thomas Koenig  changed:

   What|Removed |Added

 CC||tkoenig at gcc dot gnu.org

--- Comment #17 from Thomas Koenig  ---
There is a warning now:

$ gfortran -O -Wall a.f90
a.f90:3:0:

 a(1)=2*b(1)

Warning: ‘b.offset’ is used uninitialized in this function [-Wuninitialized]
a.f90:3:0: Warning: ‘a.offset’ is used uninitialized in this function
[-Wuninitialized]
a.f90:3:0:

 a(1)=2*b(1)

Warning: ‘b.offset’ is used uninitialized in this function [-Wuninitialized]
a.f90:1:0:

 real,allocatable:: a(:),b(:)

note: ‘b.offset’ was declared here
a.f90:3:0:

 a(1)=2*b(1)

Warning: ‘a.offset’ is used uninitialized in this function [-Wuninitialized]
a.f90:1:0:

 real,allocatable:: a(:),b(:)

note: ‘a.offset’ was declared here

Although the text is a bit unclear it does show that something
is wrong.

So, commit a test case and close as fixed?

[Bug fortran/20520] allocatable arrays used uninitialized without a warning

2010-05-09 Thread dfranke at gcc dot gnu dot org


--- Comment #16 from dfranke at gcc dot gnu dot org  2010-05-09 18:34 
---
*** Bug 34159 has been marked as a duplicate of this bug. ***


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=20520



[Bug fortran/20520] allocatable arrays used uninitialized without a warning

2009-11-22 Thread kargl at gcc dot gnu dot org


--- Comment #15 from kargl at gcc dot gnu dot org  2009-11-22 17:37 ---
Using -fcheck=all issues a runtime error.

REMOVE:kargl[218] gfc4x -o z -Wall a2.f90
REMOVE:kargl[219] ./z
Segmentation fault (core dumped)
REMOVE:kargl[220] gfc4x -o z -Wall -fcheck=all a2.f90
REMOVE:kargl[221] ./z
At line 3 of file a2.f90
Fortran runtime error: Index '1' of dimension 1 of array 'b' above upper bound
of 0


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=20520



[Bug fortran/20520] allocatable arrays used uninitialized without a warning

2009-03-29 Thread fxcoudert at gcc dot gnu dot org


--- Comment #11 from fxcoudert at gcc dot gnu dot org  2009-03-29 07:51 
---
*** Bug 36761 has been marked as a duplicate of this bug. ***


-- 

fxcoudert at gcc dot gnu dot org changed:

   What|Removed |Added

 CC||terry at chem dot gu dot se


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=20520



[Bug fortran/20520] allocatable arrays used uninitialized without a warning

2009-03-29 Thread jvdelisle at gcc dot gnu dot org


--- Comment #12 from jvdelisle at gcc dot gnu dot org  2009-03-30 00:51 
---
The original code case is invalid.  An array that has been declared allocatable
has no size and it is invalid to use it anywhere except in an allocate or
allocated statement.


-- 

jvdelisle at gcc dot gnu dot org changed:

   What|Removed |Added

   Keywords||accepts-invalid


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=20520



[Bug fortran/20520] allocatable arrays used uninitialized without a warning

2009-03-29 Thread jvdelisle at gcc dot gnu dot org


--- Comment #13 from jvdelisle at gcc dot gnu dot org  2009-03-30 01:01 
---
*** Bug 36761 has been marked as a duplicate of this bug. ***


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=20520



[Bug fortran/20520] allocatable arrays used uninitialized without a warning

2009-03-29 Thread jvdelisle at gcc dot gnu dot org


--- Comment #14 from jvdelisle at gcc dot gnu dot org  2009-03-30 01:08 
---
See Re: DEALLOCATED array's do not have size zero  on comp.lang.fortran for
additional discussion.


http://coding.derkeiler.com/Archive/Fortran/comp.lang.fortran/2009-03/msg00073.html


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=20520



[Bug fortran/20520] allocatable arrays used uninitialized without a warning

2007-07-10 Thread dfranke at gcc dot gnu dot org


--- Comment #10 from dfranke at gcc dot gnu dot org  2007-07-10 06:37 
---
*** Bug 32709 has been marked as a duplicate of this bug. ***


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=20520



[Bug fortran/20520] allocatable arrays used uninitialized without a warning

2007-06-25 Thread dfranke at gcc dot gnu dot org


--- Comment #8 from dfranke at gcc dot gnu dot org  2007-06-25 20:37 ---
Cross-reference: the other way round, warn if allocatable is already allocated:
PR30676.


-- 

dfranke at gcc dot gnu dot org changed:

   What|Removed |Added

 CC||dfranke at gcc dot gnu dot
   ||org


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=20520



[Bug fortran/20520] allocatable arrays used uninitialized without a warning

2007-06-25 Thread burnus at gcc dot gnu dot org


--- Comment #9 from burnus at gcc dot gnu dot org  2007-06-25 20:49 ---
Besides local allocated variables, one can think of local pointers as well:

integer, pointer :: a
a = 4 ! wrong
if(associated(a)) ! wrong
nullify(a)
if(associated(a)) ! ok
a = 4 ! wrong

For allocation, one could also think about:

subroutine foo(a)
  integer, intent(out), allocatable :: a(:)
  a = 5 ! wrong: error!
-
interface
  subroutine bar1(x); integer, intent(in), allocatable :: x(:); end subroutine
  subroutine bar2(x); integer :: x(:); end subroutine
end interface
integer, allocatable :: a(:)
! call bar1(a) ! ok as if(allocated(a)) is used - no warning
! -- or --
call bar2(a) ! invalid though harmless as long bar2 does not use the variable
 ! - warning

Analogously, for pointer, except that one could check for NULL as well:
interface
  subroutine bar1(x); integer, intent(in), pointer :: x(:); end subroutine
  subroutine bar2(x); integer :: x(:); end subroutine
end interface
integer, allocatable :: a(:)
call bar1(a) ! potentially invalid (unless bar1 does not use the variable)
 ! as the pointer has unknown status - warning
call bar2(a) ! wrong (harmless if not accessed) - warning
nullify(a)
call bar2(a) ! - invalid (unless bar2 does not use the variable) - warning


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=20520



[Bug fortran/20520] allocatable arrays used uninitialized without a warning

2007-06-20 Thread dfranke at gcc dot gnu dot org


--- Comment #6 from dfranke at gcc dot gnu dot org  2007-06-20 17:18 ---
*** Bug 32430 has been marked as a duplicate of this bug. ***


-- 

dfranke at gcc dot gnu dot org changed:

   What|Removed |Added

 CC||burnus at gcc dot gnu dot
   ||org


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=20520



[Bug fortran/20520] allocatable arrays used uninitialized without a warning

2007-06-20 Thread burnus at gcc dot gnu dot org


--- Comment #7 from burnus at gcc dot gnu dot org  2007-06-20 17:39 ---
 Even ICC 8.1 accepts the code without warnings
I never found ifort (or sunf95) especially picky - contrary to NAG f95, which
is often too picky.

I'm in favour of giving a warning; actually I would even warn by default and
not only when using -W*. There is hardly any code imaginable which makes sense
and uses not allocated variables. (The only thing which comes into my mind is
code where the non-allocated variables are never accessed: dead if branch, not
calling the subroutine w/ that variable etc.)

NAG f95:
Error: x.f90, line 5: ALLOCATABLE array B used but never ALLOCATEd
   detected at END@end-of-statement
Error: x.f90, line 5: ALLOCATABLE array A used but never ALLOCATEd
   detected at END@end-of-statement

g95: Nothing by default, but with -Wall:
Warning (147): Variable 'b' at (1) is used and never allocated
Warning (112): Variable 'a' at (1) is set but never used


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=20520



[Bug fortran/20520] allocatable arrays used uninitialized without a warning

2005-03-20 Thread tobi at gcc dot gnu dot org

--- Additional Comments From tobi at gcc dot gnu dot org  2005-03-20 18:14 
---
real,allocatable:: a(:),b(:)
real::x
a(1)=2*b(1) + x
end

This only gives an uninitialized warning for x, but not for a or b:
[EMAIL PROTECTED] tests]$ gfortran -O -Wuninitialized pr20521.f90
pr20521.f90: In function ‘MAIN__’:
pr20521.f90:3: warning: ‘x’ is used uninitialized in this function

So it looks like diagnostics for allocatable arrays are fairly weak.

-- 
   What|Removed |Added

Summary|allocatable arrays used |allocatable arrays used
   |without being allocated |uninitialized without a
   |without a warning   |warning


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=20520


[Bug fortran/20520] allocatable arrays used uninitialized without a warning

2005-03-20 Thread ebertakis at gmail dot com

--- Additional Comments From ebertakis at gmail dot com  2005-03-20 19:22 
---
(In reply to comment #4)
This case is slightly different. The compiler just warns you that you are using
variable x before its value have been defined. Many programmers (that have bad
programming habits :-) probably that includes myself!) take for granted that
variables have an initial value equal to 0 once their memory space is reserved
upon definition as e.g. real. That is not always true and is heavily dependant
on the compiler that is used. Many compilers fill the variables with garbage
when they are first declared. See also the Fortran FAQ (paragraph 3.2.3):
http://www.faqs.org/faqs/fortran-faq/
That is why you got that warning. I believe it is not related to the array 
usage.

-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=20520