public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/36761]  New: Unallocated array "referenced" silently
@ 2008-07-08  7:03 terry at chem dot gu dot se
  2008-07-08  9:04 ` [Bug fortran/36761] " dfranke at gcc dot gnu dot org
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: terry at chem dot gu dot se @ 2008-07-08  7:03 UTC (permalink / raw)
  To: gcc-bugs

I'm really not sure whether to consider this a bug or a "feature".  It
certainly *seems* to me that it's non-conforming code that compiles and runs
happily.


[tjf@rscpc28 BadStuff]$ cat alloc.f90
module aa
implicit none
real(kind=8),dimension(:,:),allocatable::Md
end module aa

program fred
use aa
implicit none
write(*,*)allocated(Md)
write(*,*)Md(1,:)
end
[tjf@rscpc28 BadStuff]$ gfortran -Wall -O0 -W -Wtabs -g -fbounds-check
-fbacktrace -pedantic -std=f95 -o alloc alloc.f90
[tjf@rscpc28 BadStuff]$ ./alloc
 F

[tjf@rscpc28 BadStuff]$ gfortran -v
Using built-in specs.
Target: i686-pc-linux-gnu
Configured with: ../gcc-4.3-20080626/configure --disable-multilib
--enable-languages=c,c++,fortran
Thread model: posix
gcc version 4.3.2 20080626 (prerelease) (GCC) 



If Md is in not in a module running ./alloc segfaults.  Using a definite
element gets picked up as a bounds violation.  Writing Md(1,1:0) gives the same
silent output as above.

Should one really consider an unallocated array to be size 0?


-- 
           Summary: Unallocated array "referenced" silently
           Product: gcc
           Version: 4.3.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: terry at chem dot gu dot se
  GCC host triplet: i686-pc-linux-gnu


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


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

* [Bug fortran/36761] Unallocated array "referenced" silently
  2008-07-08  7:03 [Bug fortran/36761] New: Unallocated array "referenced" silently terry at chem dot gu dot se
@ 2008-07-08  9:04 ` dfranke at gcc dot gnu dot org
  2009-03-28 12:19 ` fxcoudert at gcc dot gnu dot org
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: dfranke at gcc dot gnu dot org @ 2008-07-08  9:04 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from dfranke at gcc dot gnu dot org  2008-07-08 09:03 -------
Very similar to PR20520.


-- 


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


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

* [Bug fortran/36761] Unallocated array "referenced" silently
  2008-07-08  7:03 [Bug fortran/36761] New: Unallocated array "referenced" silently terry at chem dot gu dot se
  2008-07-08  9:04 ` [Bug fortran/36761] " dfranke at gcc dot gnu dot org
@ 2009-03-28 12:19 ` fxcoudert at gcc dot gnu dot org
  2009-03-29  7:51 ` fxcoudert at gcc dot gnu dot org
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: fxcoudert at gcc dot gnu dot org @ 2009-03-28 12:19 UTC (permalink / raw)
  To: gcc-bugs



-- 

fxcoudert at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
     Ever Confirmed|0                           |1
   GCC host triplet|i686-pc-linux-gnu           |
   Last reconfirmed|0000-00-00 00:00:00         |2009-03-28 12:19:18
               date|                            |


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


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

* [Bug fortran/36761] Unallocated array "referenced" silently
  2008-07-08  7:03 [Bug fortran/36761] New: Unallocated array "referenced" silently terry at chem dot gu dot se
  2008-07-08  9:04 ` [Bug fortran/36761] " dfranke at gcc dot gnu dot org
  2009-03-28 12:19 ` fxcoudert at gcc dot gnu dot org
@ 2009-03-29  7:51 ` fxcoudert at gcc dot gnu dot org
  2009-03-29 23:50 ` terry at chem dot gu dot se
  2009-03-30  1:02 ` jvdelisle at gcc dot gnu dot org
  4 siblings, 0 replies; 6+ messages in thread
From: fxcoudert at gcc dot gnu dot org @ 2009-03-29  7:51 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from fxcoudert at gcc dot gnu dot org  2009-03-29 07:51 -------


*** This bug has been marked as a duplicate of 20520 ***


-- 

fxcoudert at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |DUPLICATE


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


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

* [Bug fortran/36761] Unallocated array "referenced" silently
  2008-07-08  7:03 [Bug fortran/36761] New: Unallocated array "referenced" silently terry at chem dot gu dot se
                   ` (2 preceding siblings ...)
  2009-03-29  7:51 ` fxcoudert at gcc dot gnu dot org
@ 2009-03-29 23:50 ` terry at chem dot gu dot se
  2009-03-30  1:02 ` jvdelisle at gcc dot gnu dot org
  4 siblings, 0 replies; 6+ messages in thread
From: terry at chem dot gu dot se @ 2009-03-29 23:50 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #3 from terry at chem dot gu dot se  2009-03-29 23:50 -------
Not a dupe of PR20520.  That one is for questionable code producing (or not)
some unexpected (to some) output, and crashing when run.  This is illegal code
that compiles AND RUNS quietly.  Here unallocated is giving the same behaviour
as size 0.  The array residing in a module matters in this case.

I've just tried it again with the same result.  If I insert a
write(*,*)size(Md,1),size(Md,2) and run it, it prints two 1s.


-- 

terry at chem dot gu dot se changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|RESOLVED                    |REOPENED
         Resolution|DUPLICATE                   |


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


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

* [Bug fortran/36761] Unallocated array "referenced" silently
  2008-07-08  7:03 [Bug fortran/36761] New: Unallocated array "referenced" silently terry at chem dot gu dot se
                   ` (3 preceding siblings ...)
  2009-03-29 23:50 ` terry at chem dot gu dot se
@ 2009-03-30  1:02 ` jvdelisle at gcc dot gnu dot org
  4 siblings, 0 replies; 6+ messages in thread
From: jvdelisle at gcc dot gnu dot org @ 2009-03-30  1:02 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #4 from jvdelisle at gcc dot gnu dot org  2009-03-30 01:01 -------
The first right statement in the original test case  is valid fortran and gives
the correct result.

The second write statement is invalid Fortran. An unallocated allocatable array
has no size. It is up to the programmer to use "allocated" to confirm that the
array has a size before using it.  This is what allocated is for.

Therefore this gets down to the same issue as 20520, using an allocatable array
before it is allocated. This is regardless of how it is invalidly used, in an
arithmetic statement or a write statement. See comments I added 20 20520.

*** This bug has been marked as a duplicate of 20520 ***


-- 

jvdelisle at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|REOPENED                    |RESOLVED
           Keywords|                            |accepts-invalid
         Resolution|                            |DUPLICATE


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


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

end of thread, other threads:[~2009-03-30  1:02 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-07-08  7:03 [Bug fortran/36761] New: Unallocated array "referenced" silently terry at chem dot gu dot se
2008-07-08  9:04 ` [Bug fortran/36761] " dfranke at gcc dot gnu dot org
2009-03-28 12:19 ` fxcoudert at gcc dot gnu dot org
2009-03-29  7:51 ` fxcoudert at gcc dot gnu dot org
2009-03-29 23:50 ` terry at chem dot gu dot se
2009-03-30  1:02 ` jvdelisle at gcc dot gnu dot org

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