public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/45424] F2008: Add is_contiguous intrinsic
       [not found] <bug-45424-4@http.gcc.gnu.org/bugzilla/>
@ 2012-05-09 15:38 ` burnus at gcc dot gnu.org
  2012-05-09 16:08 ` burnus at gcc dot gnu.org
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 7+ messages in thread
From: burnus at gcc dot gnu.org @ 2012-05-09 15:38 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #1 from Tobias Burnus <burnus at gcc dot gnu.org> 2012-05-09 15:36:40 UTC ---
Created attachment 27359
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=27359
Draft patch: is_contiguous.diff

Attached is a mostly ready patch for IS_CONTIGUOUS.

The main TODO is to understand when IS_CONTIGUOUS should print .TRUE. and when
.FALSE. The standard is not very clear about it, cf. 5.3.7 of F2008.


a) Array element with nonzero strides (which is still a single array element):
"a(1:1:1)" vs. "a(1:1:5)". With the attached patch but also with ifort and
crayftn, the result is .true. and .false. The attached patch only checks the
"stride", ignoring the number of elements.

b) The same - but instead of a single element, using zero-sized arrays:
a(2:1:1) vs. a(2:1:2).

c) The following example is mishandled as we have a stride and not a stride
multiplied (sm):

type t
  integer :: i, j
end type t
type(t) :: x(5)
print *, is_contiguous(x(:)) ! Shall be (and is) true
print *, is_contiguous(x(:)%i) ! Shall be false - but prints "true".
end

The fortran-devel solution would be to use: sm == TYPE_SIZE(a%i). The trunk
solution is to compare the array spec's object "a" with the the type-size of
"a%i" - and if it differs to abort.

d) The gfc_is_simply_contiguous function needs to be refined and extended - and
a "gfc_is_simply_noncontiguous" has to be added.

e) More tests are needed - including polymorphic arrays and compile-time checks
for the code in simplify.c. [Which is related to (d).]

f) For TS29113, one needs to handle assumed-rank arrays, including rank-1 ones.
Again the question is whether the dummy argument associated with a scalar is
then contiguous or not.


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

* [Bug fortran/45424] F2008: Add is_contiguous intrinsic
       [not found] <bug-45424-4@http.gcc.gnu.org/bugzilla/>
  2012-05-09 15:38 ` [Bug fortran/45424] F2008: Add is_contiguous intrinsic burnus at gcc dot gnu.org
@ 2012-05-09 16:08 ` burnus at gcc dot gnu.org
  2013-04-19 21:12 ` quantheory at gmail dot com
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 7+ messages in thread
From: burnus at gcc dot gnu.org @ 2012-05-09 16:08 UTC (permalink / raw)
  To: gcc-bugs

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

Tobias Burnus <burnus at gcc dot gnu.org> changed:

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

--- Comment #2 from Tobias Burnus <burnus at gcc dot gnu.org> 2012-05-09 16:02:18 UTC ---
(In reply to comment #1)
> a) Array element with nonzero strides

I meant: A an array containing a single element and having a nonunity stride.


> type t
>   integer :: i, j
> end type t
> print *, is_contiguous(x(:)%i) ! Shall be false - but prints "true".

Those kind of arguments can get really tricky! Assume as component a:
    integer :: i(1) ! or "i(2)
or
    class(t), allocatable :: a
or
    integer, allocatable :: a(:)
which is accessed as "is_contiguous(x(:)%a(1))".

Intel and Cray handle it simply: by always returning "F" - even for "type t;
integer :: i; end type", which should have no padding and be contiguous in
memory. We could do the same - or we rule out BT_CLASS, arrays and coarrays and
do then a size check: whole derived type == expr->ts.type size.


Another issue are substrings. For those one needs to check that the substring
range matches the string length.


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

* [Bug fortran/45424] F2008: Add is_contiguous intrinsic
       [not found] <bug-45424-4@http.gcc.gnu.org/bugzilla/>
  2012-05-09 15:38 ` [Bug fortran/45424] F2008: Add is_contiguous intrinsic burnus at gcc dot gnu.org
  2012-05-09 16:08 ` burnus at gcc dot gnu.org
@ 2013-04-19 21:12 ` quantheory at gmail dot com
  2013-04-20 17:41 ` [Bug fortran/45424] [F2008] Add IS_CONTIGUOUS intrinsic janus at gcc dot gnu.org
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 7+ messages in thread
From: quantheory at gmail dot com @ 2013-04-19 21:12 UTC (permalink / raw)
  To: gcc-bugs


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

Sean Santos <quantheory at gmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |quantheory at gmail dot com

--- Comment #3 from Sean Santos <quantheory at gmail dot com> 2013-04-19 21:12:06 UTC ---
A naive interpretation of the standard suggests that in the case "a)",
is_contiguous should return .true., because the standard doesn't say anything
about strides here, only about the ordering of the elements. (Of course strides
matter for "simply contiguous" things, but that's different.)

Case "b)" seems to be the same.

In case "f)", since scalars can be associated with assumed-rank entities that
have the contiguous attribute, it wouldn't make much sense to return ".false."
in this case.


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

* [Bug fortran/45424] [F2008] Add IS_CONTIGUOUS intrinsic
       [not found] <bug-45424-4@http.gcc.gnu.org/bugzilla/>
                   ` (2 preceding siblings ...)
  2013-04-19 21:12 ` quantheory at gmail dot com
@ 2013-04-20 17:41 ` janus at gcc dot gnu.org
  2013-12-20 23:20 ` [Bug fortran/45424] [F08] " janus at gcc dot gnu.org
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 7+ messages in thread
From: janus at gcc dot gnu.org @ 2013-04-20 17:41 UTC (permalink / raw)
  To: gcc-bugs


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

janus at gcc dot gnu.org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |janus at gcc dot gnu.org
            Summary|F2008: Add is_contiguous    |[F2008] Add IS_CONTIGUOUS
                   |intrinsic                   |intrinsic

--- Comment #4 from janus at gcc dot gnu.org 2013-04-20 17:41:22 UTC ---
(In reply to comment #1)
> d) The gfc_is_simply_contiguous function needs to be refined and extended - and
> a "gfc_is_simply_noncontiguous" has to be added.

Another application for 'gfc_is_simply_noncontiguous' would be to reject
invalid code like

  integer, dimension(1:5,1:5), target :: zzz
  type(c_ptr) :: ptr
  ptr = c_loc (zzz(4:,4:))

cf. http://gcc.gnu.org/ml/fortran/2013-04/msg00181.html and follow-ups.


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

* [Bug fortran/45424] [F08] Add IS_CONTIGUOUS intrinsic
       [not found] <bug-45424-4@http.gcc.gnu.org/bugzilla/>
                   ` (3 preceding siblings ...)
  2013-04-20 17:41 ` [Bug fortran/45424] [F2008] Add IS_CONTIGUOUS intrinsic janus at gcc dot gnu.org
@ 2013-12-20 23:20 ` janus at gcc dot gnu.org
  2020-07-29 10:18 ` markeggleston at gcc dot gnu.org
  2020-07-29 14:32 ` dominiq at lps dot ens.fr
  6 siblings, 0 replies; 7+ messages in thread
From: janus at gcc dot gnu.org @ 2013-12-20 23:20 UTC (permalink / raw)
  To: gcc-bugs

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

janus at gcc dot gnu.org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2013-12-20
            Summary|[F2008] Add IS_CONTIGUOUS   |[F08] Add IS_CONTIGUOUS
                   |intrinsic                   |intrinsic
     Ever confirmed|0                           |1


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

* [Bug fortran/45424] [F08] Add IS_CONTIGUOUS intrinsic
       [not found] <bug-45424-4@http.gcc.gnu.org/bugzilla/>
                   ` (4 preceding siblings ...)
  2013-12-20 23:20 ` [Bug fortran/45424] [F08] " janus at gcc dot gnu.org
@ 2020-07-29 10:18 ` markeggleston at gcc dot gnu.org
  2020-07-29 14:32 ` dominiq at lps dot ens.fr
  6 siblings, 0 replies; 7+ messages in thread
From: markeggleston at gcc dot gnu.org @ 2020-07-29 10:18 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=45424
Bug 45424 depends on bug 53298, which changed state.

Bug 53298 Summary: ICE in gfc_conv_scalarized_array_ref for ARRAY + substring
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=53298

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

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

* [Bug fortran/45424] [F08] Add IS_CONTIGUOUS intrinsic
       [not found] <bug-45424-4@http.gcc.gnu.org/bugzilla/>
                   ` (5 preceding siblings ...)
  2020-07-29 10:18 ` markeggleston at gcc dot gnu.org
@ 2020-07-29 14:32 ` dominiq at lps dot ens.fr
  6 siblings, 0 replies; 7+ messages in thread
From: dominiq at lps dot ens.fr @ 2020-07-29 14:32 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=45424
Bug 45424 depends on bug 53298, which changed state.

Bug 53298 Summary: ICE in gfc_conv_scalarized_array_ref for ARRAY + substring
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=53298

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

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

end of thread, other threads:[~2020-07-29 14:32 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <bug-45424-4@http.gcc.gnu.org/bugzilla/>
2012-05-09 15:38 ` [Bug fortran/45424] F2008: Add is_contiguous intrinsic burnus at gcc dot gnu.org
2012-05-09 16:08 ` burnus at gcc dot gnu.org
2013-04-19 21:12 ` quantheory at gmail dot com
2013-04-20 17:41 ` [Bug fortran/45424] [F2008] Add IS_CONTIGUOUS intrinsic janus at gcc dot gnu.org
2013-12-20 23:20 ` [Bug fortran/45424] [F08] " janus at gcc dot gnu.org
2020-07-29 10:18 ` markeggleston at gcc dot gnu.org
2020-07-29 14:32 ` dominiq at lps dot ens.fr

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