public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/104346] New: Problem with overloaded assignment when LHS is allocatable array
@ 2022-02-02 15:47 vivekrao4 at yahoo dot com
  2022-02-02 17:22 ` [Bug fortran/104346] " vivekrao4 at yahoo dot com
  2023-02-15 19:40 ` anlauf at gcc dot gnu.org
  0 siblings, 2 replies; 3+ messages in thread
From: vivekrao4 at yahoo dot com @ 2022-02-02 15:47 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 104346
           Summary: Problem with overloaded assignment when LHS is
                    allocatable array
           Product: gcc
           Version: 12.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
          Assignee: unassigned at gcc dot gnu.org
          Reporter: vivekrao4 at yahoo dot com
  Target Milestone: ---

For the code 

module assignment_mod
implicit none
interface assignment(=)
   module procedure int_from_char
end interface
contains
elemental subroutine int_from_char(i,s)
integer, intent(out) :: i
character (len=*), intent(in) :: s
read (s,*) i
end subroutine int_from_char
end module assignment_mod
!
program test_assignment
use assignment_mod, only: assignment(=)
implicit none
integer :: j,k(2)
integer, allocatable :: ialloc(:)
j = "4"
print*,"j=",j
k = ["4","9"]
print*,"k=",k
ialloc = ["4","9"]
print*,"ialloc=",ialloc
end program test_assignment

compiling with GNU Fortran (GCC) 12.0.0 20211024 (experimental) from
equation.com and running gives

 j=           4
 k=           4           9

Program received signal SIGSEGV: Segmentation fault - invalid memory reference.

Intel Fortran also has trouble with the code:
https://community.intel.com/t5/Intel-Fortran-Compiler/Problem-with-overloaded-assignment-when-LHS-is-allocatable-array/m-p/1356724/emcs_t/S2h8ZW1haWx8dG9waWNfc3Vic2NyaXB0aW9ufEtaNVBQV1dXUDkxOTBHfDEzNTY3MjR8U1VCU0NSSVBUSU9OU3xoSw#M159809
.

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

* [Bug fortran/104346] Problem with overloaded assignment when LHS is allocatable array
  2022-02-02 15:47 [Bug fortran/104346] New: Problem with overloaded assignment when LHS is allocatable array vivekrao4 at yahoo dot com
@ 2022-02-02 17:22 ` vivekrao4 at yahoo dot com
  2023-02-15 19:40 ` anlauf at gcc dot gnu.org
  1 sibling, 0 replies; 3+ messages in thread
From: vivekrao4 at yahoo dot com @ 2022-02-02 17:22 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #1 from Vivek Rao <vivekrao4 at yahoo dot com> ---
It is explained at
https://community.intel.com/t5/Intel-Fortran-Compiler/Problem-with-overloaded-assignment-when-LHS-is-allocatable-array/m-p/1356757/highlight/true#M159812
that the code is not conforming, so this issue can be closed.

"In this case, the standard essentially places the onus on the program (and by
extension its author) to conform, the processor (compiler being part of it) is
not required to issue diagnostics.

And the issue is this: with the defined assignment as specified, the standard
semantics requires the 'ialloc` to be allocated to the right shape prior to
assignment on line 23: "ialloc = ["4","9"]".

You can retry with `allocate( ialloc(2) )` statement preceding the above
assignment and check the program response."

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

* [Bug fortran/104346] Problem with overloaded assignment when LHS is allocatable array
  2022-02-02 15:47 [Bug fortran/104346] New: Problem with overloaded assignment when LHS is allocatable array vivekrao4 at yahoo dot com
  2022-02-02 17:22 ` [Bug fortran/104346] " vivekrao4 at yahoo dot com
@ 2023-02-15 19:40 ` anlauf at gcc dot gnu.org
  1 sibling, 0 replies; 3+ messages in thread
From: anlauf at gcc dot gnu.org @ 2023-02-15 19:40 UTC (permalink / raw)
  To: gcc-bugs

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

anlauf at gcc dot gnu.org changed:

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

--- Comment #2 from anlauf at gcc dot gnu.org ---
(In reply to Vivek Rao from comment #1)
> It is explained at
> https://community.intel.com/t5/Intel-Fortran-Compiler/Problem-with-
> overloaded-assignment-when-LHS-is-allocatable-array/m-p/1356757/highlight/
> true#M159812 that the code is not conforming, so this issue can be closed.

Thanks for following up.

This is also confirmed by checking with e.g. NAG.  Thus closing.

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

end of thread, other threads:[~2023-02-15 19:40 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-02-02 15:47 [Bug fortran/104346] New: Problem with overloaded assignment when LHS is allocatable array vivekrao4 at yahoo dot com
2022-02-02 17:22 ` [Bug fortran/104346] " vivekrao4 at yahoo dot com
2023-02-15 19:40 ` anlauf at gcc dot gnu.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).