[all-commits] [llvm/llvm-project] f546b6: [Flang] Relaxing an error when contiguous pointer ...

harishch4 via All-commits all-commits at lists.llvm.org
Mon Apr 1 04:43:45 PDT 2024


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: f546b6ef3c15a156959dde16fa5f03a350a0a2be
      https://github.com/llvm/llvm-project/commit/f546b6ef3c15a156959dde16fa5f03a350a0a2be
  Author: harishch4 <harishcse44 at gmail.com>
  Date:   2024-04-01 (Mon, 01 Apr 2024)

  Changed paths:
    M flang/lib/Semantics/pointer-assignment.cpp

  Log Message:
  -----------
  [Flang] Relaxing an error when contiguous pointer is assigned to a non-contig… (#86781)

…uous function.

Fix from [thtsikas](https://github.com/thtsikas) based on a discussion
in
[slack](https://flang-compiler.slack.com/archives/C5C58TT32/p1711124374836079).

Example:
```
Program test
  Integer, Pointer, Contiguous :: cont(:)
  Interface
     Function f()
       Integer, Pointer :: f(:)
     End Function
  End Interface
  cont => f()
  Print *, cont(3)
End Program

Function f()
  Integer, Pointer :: f(:)
  Allocate (f(4),Source=[1,1,42,1])
  ! f => f(4:1:-1)        !! not contiguous, runtime error
End Function f
```

Understanding is that the standard intended to allow this pattern. The
restriction 10.2.2.3 p6 Data pointer assignment "If the pointer object
has the CONTIGUOUS attribute, the pointer target shall be contiguous."
is not associated with a numbered constraint. If there is a mechanism
for injecting runtime checks, this would be a place to do it. Absent
that, a warning is the best we can do.

No other compiler treats contigPtr => func() as an error when func() is
not CONTIGUOUS, so a warning would probably be better for consistency.
https://godbolt.org/z/5cM6roeEE



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list