public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/105759] New: is_contiguous(zero_size_array(2:0)) wrongly returns .true.
@ 2022-05-28 15:48 burnus at gcc dot gnu.org
  2022-05-28 18:04 ` [Bug fortran/105759] " kargl at gcc dot gnu.org
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: burnus at gcc dot gnu.org @ 2022-05-28 15:48 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 105759
           Summary: is_contiguous(zero_size_array(2:0)) wrongly returns
                    .true.
           Product: gcc
           Version: 13.0
            Status: UNCONFIRMED
          Keywords: wrong-code
          Severity: normal
          Priority: P3
         Component: fortran
          Assignee: unassigned at gcc dot gnu.org
          Reporter: burnus at gcc dot gnu.org
  Target Milestone: ---

GCC and ifort both return T for the following code:

integer :: a(2)
print *, is_contiguous(a(2:1))
end


However, I think that should be F / .false. as F2018 has:

8.5.7 CONTIGUOUS attribute
...
An object is contiguous if it is
...
(7) a nonzero-sized array section (9.5.3) provided that
...


Disclaimer: I might have missed something.


If it is a bug, then we probably need to fix both the simplify.cc compile-time
and libgfortran run-time check.

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

* [Bug fortran/105759] is_contiguous(zero_size_array(2:0)) wrongly returns .true.
  2022-05-28 15:48 [Bug fortran/105759] New: is_contiguous(zero_size_array(2:0)) wrongly returns .true burnus at gcc dot gnu.org
@ 2022-05-28 18:04 ` kargl at gcc dot gnu.org
  2022-05-31  9:59 ` anlauf at gcc dot gnu.org
  2022-05-31 16:27 ` sgk at troutmask dot apl.washington.edu
  2 siblings, 0 replies; 4+ messages in thread
From: kargl at gcc dot gnu.org @ 2022-05-28 18:04 UTC (permalink / raw)
  To: gcc-bugs

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

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 ---
(In reply to Tobias Burnus from comment #0)
> GCC and ifort both return T for the following code:
> 
> integer :: a(2)
> print *, is_contiguous(a(2:1))
> end
> 
> 
> However, I think that should be F / .false. as F2018 has:
> 
> 8.5.7 CONTIGUOUS attribute
> ...
> An object is contiguous if it is
> ...
> (7) a nonzero-sized array section (9.5.3) provided that
> ...
> 
> 
> Disclaimer: I might have missed something.
> 
> 
> If it is a bug, then we probably need to fix both the simplify.cc
> compile-time and libgfortran run-time check.

I think that you may be wrongly interpreting what the standard says.  (7)
clearly does not apply to your code because a(2:1) is a zero-sized array
section.

What I think you're missing from 22-007.pdf, page 104,

   It is processor dependent whether any other object is contiguous.

and a zero-sized entity falls under this statement.  Then on page 94, we have

   An empty sequence forms a zero-sized array.

As the sequence is empty, it can be neither contiguous nor discontiguous.

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

* [Bug fortran/105759] is_contiguous(zero_size_array(2:0)) wrongly returns .true.
  2022-05-28 15:48 [Bug fortran/105759] New: is_contiguous(zero_size_array(2:0)) wrongly returns .true burnus at gcc dot gnu.org
  2022-05-28 18:04 ` [Bug fortran/105759] " kargl at gcc dot gnu.org
@ 2022-05-31  9:59 ` anlauf at gcc dot gnu.org
  2022-05-31 16:27 ` sgk at troutmask dot apl.washington.edu
  2 siblings, 0 replies; 4+ messages in thread
From: anlauf at gcc dot gnu.org @ 2022-05-31  9:59 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from anlauf at gcc dot gnu.org ---
JFTR: Cray and NAG also print T, so I guess this confirms Steve's analysis.

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

* [Bug fortran/105759] is_contiguous(zero_size_array(2:0)) wrongly returns .true.
  2022-05-28 15:48 [Bug fortran/105759] New: is_contiguous(zero_size_array(2:0)) wrongly returns .true burnus at gcc dot gnu.org
  2022-05-28 18:04 ` [Bug fortran/105759] " kargl at gcc dot gnu.org
  2022-05-31  9:59 ` anlauf at gcc dot gnu.org
@ 2022-05-31 16:27 ` sgk at troutmask dot apl.washington.edu
  2 siblings, 0 replies; 4+ messages in thread
From: sgk at troutmask dot apl.washington.edu @ 2022-05-31 16:27 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from Steve Kargl <sgk at troutmask dot apl.washington.edu> ---
On Tue, May 31, 2022 at 09:59:48AM +0000, anlauf at gcc dot gnu.org wrote:
> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105759
> 
> --- Comment #2 from anlauf at gcc dot gnu.org ---
> JFTR: Cray and NAG also print T, so I guess this confirms Steve's analysis.
> 

I asked on Fortran Discourse.  Most answers, by non-compiler
developer, believe that the answer should be F.  I think gfortran
has it right; in particular, gfortran agrees with other implementations.

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

end of thread, other threads:[~2022-05-31 16:27 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-28 15:48 [Bug fortran/105759] New: is_contiguous(zero_size_array(2:0)) wrongly returns .true burnus at gcc dot gnu.org
2022-05-28 18:04 ` [Bug fortran/105759] " kargl at gcc dot gnu.org
2022-05-31  9:59 ` anlauf at gcc dot gnu.org
2022-05-31 16:27 ` 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).