public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/20520] allocatable arrays used uninitialized without a warning
       [not found] <bug-20520-10294@http.gcc.gnu.org/bugzilla/>
@ 2007-06-20 17:19 ` dfranke at gcc dot gnu dot org
  2007-06-20 17:40 ` burnus at gcc dot gnu dot org
                   ` (9 subsequent siblings)
  10 siblings, 0 replies; 13+ messages in thread
From: dfranke at gcc dot gnu dot org @ 2007-06-20 17:19 UTC (permalink / raw)
  To: gcc-bugs



------- 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


^ permalink raw reply	[flat|nested] 13+ messages in thread

* [Bug fortran/20520] allocatable arrays used uninitialized without a warning
       [not found] <bug-20520-10294@http.gcc.gnu.org/bugzilla/>
  2007-06-20 17:19 ` [Bug fortran/20520] allocatable arrays used uninitialized without a warning dfranke at gcc dot gnu dot org
@ 2007-06-20 17:40 ` burnus at gcc dot gnu dot org
  2007-06-25 20:37 ` dfranke at gcc dot gnu dot org
                   ` (8 subsequent siblings)
  10 siblings, 0 replies; 13+ messages in thread
From: burnus at gcc dot gnu dot org @ 2007-06-20 17:40 UTC (permalink / raw)
  To: gcc-bugs



------- 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


^ permalink raw reply	[flat|nested] 13+ messages in thread

* [Bug fortran/20520] allocatable arrays used uninitialized without a warning
       [not found] <bug-20520-10294@http.gcc.gnu.org/bugzilla/>
  2007-06-20 17:19 ` [Bug fortran/20520] allocatable arrays used uninitialized without a warning dfranke at gcc dot gnu dot org
  2007-06-20 17:40 ` burnus at gcc dot gnu dot org
@ 2007-06-25 20:37 ` dfranke at gcc dot gnu dot org
  2007-06-25 20:50 ` burnus at gcc dot gnu dot org
                   ` (7 subsequent siblings)
  10 siblings, 0 replies; 13+ messages in thread
From: dfranke at gcc dot gnu dot org @ 2007-06-25 20:37 UTC (permalink / raw)
  To: gcc-bugs



------- 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


^ permalink raw reply	[flat|nested] 13+ messages in thread

* [Bug fortran/20520] allocatable arrays used uninitialized without a warning
       [not found] <bug-20520-10294@http.gcc.gnu.org/bugzilla/>
                   ` (2 preceding siblings ...)
  2007-06-25 20:37 ` dfranke at gcc dot gnu dot org
@ 2007-06-25 20:50 ` burnus at gcc dot gnu dot org
  2007-07-10  6:37 ` dfranke at gcc dot gnu dot org
                   ` (6 subsequent siblings)
  10 siblings, 0 replies; 13+ messages in thread
From: burnus at gcc dot gnu dot org @ 2007-06-25 20:50 UTC (permalink / raw)
  To: gcc-bugs



------- 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


^ permalink raw reply	[flat|nested] 13+ messages in thread

* [Bug fortran/20520] allocatable arrays used uninitialized without a warning
       [not found] <bug-20520-10294@http.gcc.gnu.org/bugzilla/>
                   ` (3 preceding siblings ...)
  2007-06-25 20:50 ` burnus at gcc dot gnu dot org
@ 2007-07-10  6:37 ` dfranke at gcc dot gnu dot org
  2009-03-29  7:51 ` fxcoudert at gcc dot gnu dot org
                   ` (5 subsequent siblings)
  10 siblings, 0 replies; 13+ messages in thread
From: dfranke at gcc dot gnu dot org @ 2007-07-10  6:37 UTC (permalink / raw)
  To: gcc-bugs



------- 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


^ permalink raw reply	[flat|nested] 13+ messages in thread

* [Bug fortran/20520] allocatable arrays used uninitialized without a warning
       [not found] <bug-20520-10294@http.gcc.gnu.org/bugzilla/>
                   ` (4 preceding siblings ...)
  2007-07-10  6:37 ` dfranke at gcc dot gnu dot org
@ 2009-03-29  7:51 ` fxcoudert at gcc dot gnu dot org
  2009-03-30  0:51 ` jvdelisle at gcc dot gnu dot org
                   ` (4 subsequent siblings)
  10 siblings, 0 replies; 13+ messages in thread
From: fxcoudert at gcc dot gnu dot org @ 2009-03-29  7:51 UTC (permalink / raw)
  To: gcc-bugs



------- 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


^ permalink raw reply	[flat|nested] 13+ messages in thread

* [Bug fortran/20520] allocatable arrays used uninitialized without a warning
       [not found] <bug-20520-10294@http.gcc.gnu.org/bugzilla/>
                   ` (5 preceding siblings ...)
  2009-03-29  7:51 ` fxcoudert at gcc dot gnu dot org
@ 2009-03-30  0:51 ` jvdelisle at gcc dot gnu dot org
  2009-03-30  1:02 ` jvdelisle at gcc dot gnu dot org
                   ` (3 subsequent siblings)
  10 siblings, 0 replies; 13+ messages in thread
From: jvdelisle at gcc dot gnu dot org @ 2009-03-30  0:51 UTC (permalink / raw)
  To: gcc-bugs



------- 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


^ permalink raw reply	[flat|nested] 13+ messages in thread

* [Bug fortran/20520] allocatable arrays used uninitialized without a warning
       [not found] <bug-20520-10294@http.gcc.gnu.org/bugzilla/>
                   ` (6 preceding siblings ...)
  2009-03-30  0:51 ` jvdelisle at gcc dot gnu dot org
@ 2009-03-30  1:02 ` jvdelisle at gcc dot gnu dot org
  2009-03-30  1:08 ` jvdelisle at gcc dot gnu dot org
                   ` (2 subsequent siblings)
  10 siblings, 0 replies; 13+ messages in thread
From: jvdelisle at gcc dot gnu dot org @ 2009-03-30  1:02 UTC (permalink / raw)
  To: gcc-bugs



------- 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


^ permalink raw reply	[flat|nested] 13+ messages in thread

* [Bug fortran/20520] allocatable arrays used uninitialized without a warning
       [not found] <bug-20520-10294@http.gcc.gnu.org/bugzilla/>
                   ` (7 preceding siblings ...)
  2009-03-30  1:02 ` jvdelisle at gcc dot gnu dot org
@ 2009-03-30  1:08 ` jvdelisle at gcc dot gnu dot org
  2009-11-22 17:37 ` kargl at gcc dot gnu dot org
  2010-05-09 18:34 ` dfranke at gcc dot gnu dot org
  10 siblings, 0 replies; 13+ messages in thread
From: jvdelisle at gcc dot gnu dot org @ 2009-03-30  1:08 UTC (permalink / raw)
  To: gcc-bugs



------- 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


^ permalink raw reply	[flat|nested] 13+ messages in thread

* [Bug fortran/20520] allocatable arrays used uninitialized without a warning
       [not found] <bug-20520-10294@http.gcc.gnu.org/bugzilla/>
                   ` (8 preceding siblings ...)
  2009-03-30  1:08 ` jvdelisle at gcc dot gnu dot org
@ 2009-11-22 17:37 ` kargl at gcc dot gnu dot org
  2010-05-09 18:34 ` dfranke at gcc dot gnu dot org
  10 siblings, 0 replies; 13+ messages in thread
From: kargl at gcc dot gnu dot org @ 2009-11-22 17:37 UTC (permalink / raw)
  To: gcc-bugs



------- 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


^ permalink raw reply	[flat|nested] 13+ messages in thread

* [Bug fortran/20520] allocatable arrays used uninitialized without a warning
       [not found] <bug-20520-10294@http.gcc.gnu.org/bugzilla/>
                   ` (9 preceding siblings ...)
  2009-11-22 17:37 ` kargl at gcc dot gnu dot org
@ 2010-05-09 18:34 ` dfranke at gcc dot gnu dot org
  10 siblings, 0 replies; 13+ messages in thread
From: dfranke at gcc dot gnu dot org @ 2010-05-09 18:34 UTC (permalink / raw)
  To: gcc-bugs



------- 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


^ permalink raw reply	[flat|nested] 13+ messages in thread

* [Bug fortran/20520] allocatable arrays used uninitialized without a warning
  2005-03-17 17:31 [Bug fortran/20520] New: allocatable arrays may be used without being allocated ebertakis at gmail dot com
  2005-03-20 18:14 ` [Bug fortran/20520] allocatable arrays used uninitialized without a warning tobi at gcc dot gnu dot org
@ 2005-03-20 19:22 ` ebertakis at gmail dot com
  1 sibling, 0 replies; 13+ messages in thread
From: ebertakis at gmail dot com @ 2005-03-20 19:22 UTC (permalink / raw)
  To: gcc-bugs


------- 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


^ permalink raw reply	[flat|nested] 13+ messages in thread

* [Bug fortran/20520] allocatable arrays used uninitialized without a warning
  2005-03-17 17:31 [Bug fortran/20520] New: allocatable arrays may be used without being allocated ebertakis at gmail dot com
@ 2005-03-20 18:14 ` tobi at gcc dot gnu dot org
  2005-03-20 19:22 ` ebertakis at gmail dot com
  1 sibling, 0 replies; 13+ messages in thread
From: tobi at gcc dot gnu dot org @ 2005-03-20 18:14 UTC (permalink / raw)
  To: gcc-bugs

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 850 bytes --]


------- 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:
[tobi@marktplatz 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


^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2010-05-09 18:34 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <bug-20520-10294@http.gcc.gnu.org/bugzilla/>
2007-06-20 17:19 ` [Bug fortran/20520] allocatable arrays used uninitialized without a warning dfranke at gcc dot gnu dot org
2007-06-20 17:40 ` burnus at gcc dot gnu dot org
2007-06-25 20:37 ` dfranke at gcc dot gnu dot org
2007-06-25 20:50 ` burnus at gcc dot gnu dot org
2007-07-10  6:37 ` dfranke at gcc dot gnu dot org
2009-03-29  7:51 ` fxcoudert at gcc dot gnu dot org
2009-03-30  0:51 ` jvdelisle at gcc dot gnu dot org
2009-03-30  1:02 ` jvdelisle at gcc dot gnu dot org
2009-03-30  1:08 ` jvdelisle at gcc dot gnu dot org
2009-11-22 17:37 ` kargl at gcc dot gnu dot org
2010-05-09 18:34 ` dfranke at gcc dot gnu dot org
2005-03-17 17:31 [Bug fortran/20520] New: allocatable arrays may be used without being allocated ebertakis at gmail dot com
2005-03-20 18:14 ` [Bug fortran/20520] allocatable arrays used uninitialized without a warning tobi at gcc dot gnu dot org
2005-03-20 19:22 ` ebertakis at gmail dot com

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).