public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/104927] New: Invalid array size specification accepted
@ 2022-03-15  8:46 federico.perini at gmail dot com
  2022-03-15 15:27 ` [Bug fortran/104927] " kargl at gcc dot gnu.org
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: federico.perini at gmail dot com @ 2022-03-15  8:46 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104927

            Bug ID: 104927
           Summary: Invalid array size specification accepted
           Product: gcc
           Version: 10.3.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
          Assignee: unassigned at gcc dot gnu.org
          Reporter: federico.perini at gmail dot com
  Target Milestone: ---

Created attachment 52627
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=52627&action=edit
test program

A low priority bug, I guess.

The following invalid code with double array size specifications is accepted by
gfortran 10.3.0 all the way down to at least 8.1.0:

integer, allocatable, dimension(:,:) :: a(:)
integer, allocatable, dimension(:)   :: b(:,:)
integer, allocatable, dimension(:,:) :: c(:,:)

It appears that the shape then picked by gfortran is that on the right hand
side, but no errors/warning are printed. I've attached a test program for this.

Thanks for the hardwork on gfortran!
Federico

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

* [Bug fortran/104927] Invalid array size specification accepted
  2022-03-15  8:46 [Bug fortran/104927] New: Invalid array size specification accepted federico.perini at gmail dot com
@ 2022-03-15 15:27 ` kargl at gcc dot gnu.org
  2022-03-15 16:10 ` federico.perini at gmail dot com
  2022-03-15 16:34 ` sgk at troutmask dot apl.washington.edu
  2 siblings, 0 replies; 4+ messages in thread
From: kargl at gcc dot gnu.org @ 2022-03-15 15:27 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104927

kargl at gcc dot gnu.org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |kargl at gcc dot gnu.org

--- Comment #1 from kargl at gcc dot gnu.org ---
A sure that code is invalid.  F2018, p. 92.

The type declaration statement also specifies the attributes whose keywords
appear in the attr-spec, except that the DIMENSION attribute can be specified
or overridden for an entity by the appearance of array-spec in its entity-decl,
...

Modifying your code to


  program test_invalid_shape

  implicit none

  integer, dimension(3,3) :: a(4)
  integer, dimension(3)   :: b(2,2)
  integer, dimension(3,3) :: c(6,6)

  print *, 'shape(a) = ',shape(a) 
  print *, 'shape(b) = ',shape(b) 
  print *, 'shape(c) = ',shape(c) 

  end program test_invalid_shape        

gives

 shape(a) =            4
 shape(b) =            2           2
 shape(c) =            6           6

which is in line with the words from the Fortran standard.

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

* [Bug fortran/104927] Invalid array size specification accepted
  2022-03-15  8:46 [Bug fortran/104927] New: Invalid array size specification accepted federico.perini at gmail dot com
  2022-03-15 15:27 ` [Bug fortran/104927] " kargl at gcc dot gnu.org
@ 2022-03-15 16:10 ` federico.perini at gmail dot com
  2022-03-15 16:34 ` sgk at troutmask dot apl.washington.edu
  2 siblings, 0 replies; 4+ messages in thread
From: federico.perini at gmail dot com @ 2022-03-15 16:10 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104927

federico <federico.perini at gmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|---                         |INVALID

--- Comment #2 from federico <federico.perini at gmail dot com> ---
Yeah I'm surprised but wrong. The "overriding" option of the rhs size
specification is pretty clear from that statement from the standard.

This makes it even more evident: 

program test_invalid_shape
        implicit none

        integer, dimension(2,2) :: a(3),b(2,5),c

        print *, 'shape(a) = ',shape(a)
        print *, 'shape(b) = ',shape(b)
        print *, 'shape(c) = ',shape(c)

end program test_invalid_shape

produces 

 shape(a) =            3
 shape(b) =            2           5
 shape(c) =            2           2

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

* [Bug fortran/104927] Invalid array size specification accepted
  2022-03-15  8:46 [Bug fortran/104927] New: Invalid array size specification accepted federico.perini at gmail dot com
  2022-03-15 15:27 ` [Bug fortran/104927] " kargl at gcc dot gnu.org
  2022-03-15 16:10 ` federico.perini at gmail dot com
@ 2022-03-15 16:34 ` sgk at troutmask dot apl.washington.edu
  2 siblings, 0 replies; 4+ messages in thread
From: sgk at troutmask dot apl.washington.edu @ 2022-03-15 16:34 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104927

--- Comment #3 from Steve Kargl <sgk at troutmask dot apl.washington.edu> ---
On Tue, Mar 15, 2022 at 04:10:41PM +0000, federico.perini at gmail dot com
wrote:
> --- Comment #2 from federico <federico.perini at gmail dot com> ---
> Yeah I'm surprised but wrong. The "overriding" option of the rhs size
> specification is pretty clear from that statement from the standard.
> 

Thanks for the bug report.  We would rather see a bug report that
is proven to be invalid than to have actual bugs go unreported.

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

end of thread, other threads:[~2022-03-15 16:34 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-15  8:46 [Bug fortran/104927] New: Invalid array size specification accepted federico.perini at gmail dot com
2022-03-15 15:27 ` [Bug fortran/104927] " kargl at gcc dot gnu.org
2022-03-15 16:10 ` federico.perini at gmail dot com
2022-03-15 16:34 ` sgk at troutmask dot apl.washington.edu

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