public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/106317] New: deferred-length character array pointer in derived type
@ 2022-07-15 17:13 clange001 at gmail dot com
  2024-04-07 20:01 ` [Bug fortran/106317] " anlauf at gcc dot gnu.org
  2024-05-14 20:06 ` anlauf at gcc dot gnu.org
  0 siblings, 2 replies; 3+ messages in thread
From: clange001 at gmail dot com @ 2022-07-15 17:13 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 106317
           Summary: deferred-length character array pointer in derived
                    type
           Product: gcc
           Version: 11.3.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
          Assignee: unassigned at gcc dot gnu.org
          Reporter: clange001 at gmail dot com
  Target Milestone: ---

The following test program gives seg fault with fortran 11.3.  I'm trying to
store a pointer to a deferred-length character array.  The pointer I'd like to
store is in a derived type.  A regular fortran intrinsic pointer outside of the
derived type works fine, but a pointer stored in the derived type does not.  My
apologies if this has been addressed or reported elsewhere.


$ gfortran --version
GNU Fortran (MacPorts gcc11 11.3.0_1) 11.3.0
Copyright (C) 2021 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

$ cat test.f90
program test

  type t
    character(:), pointer, dimension(:) :: a_ptr
  end type
  type(t) :: mt
  character(:), pointer, dimension(:) :: a
  character(:), pointer, dimension(:) :: b_ptr

  allocate(character(len=10) :: a(3))
  a(:) = '0123456789'
  print *, a

  ! this works fine
  b_ptr => a
  print *, associated(b_ptr, a)
  print *, b_ptr

  ! does not seem work if pointer is member of derived type
  mt%a_ptr => a
  print *, associated(mt%a_ptr, a)
  print *, len(mt%a_ptr)      ! string length is NOT correct
  print *, size(mt%a_ptr)     ! array size IS correct
  print *, mt%a_ptr           ! seg fault trying to access

  print *, 'end'

end program test

$ gfortran test.f90
$ ./a.out
 012345678901234567890123456789
 T
 012345678901234567890123456789
 T
   328630909
           3

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

Backtrace for this error:
#0  0x10b2f4590
#1  0x10b2f3c1e
#2  0x7fff205b5d7c
#3  0x10b42d2c5
#4  0x10b430664
#5  0x10b4310bb
#6  0x10b2e0cfd
#7  0x10b2e0dc6
zsh: segmentation fault  ./a.out

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

* [Bug fortran/106317] deferred-length character array pointer in derived type
  2022-07-15 17:13 [Bug fortran/106317] New: deferred-length character array pointer in derived type clange001 at gmail dot com
@ 2024-04-07 20:01 ` anlauf at gcc dot gnu.org
  2024-05-14 20:06 ` anlauf at gcc dot gnu.org
  1 sibling, 0 replies; 3+ messages in thread
From: anlauf at gcc dot gnu.org @ 2024-04-07 20:01 UTC (permalink / raw)
  To: gcc-bugs

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

anlauf at gcc dot gnu.org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
      Known to fail|                            |10.5.0, 11.4.1, 12.3.0,
                   |                            |13.2.0
           Priority|P3                          |P4
                 CC|                            |anlauf at gcc dot gnu.org
      Known to work|                            |14.0
           Keywords|                            |wrong-code

--- Comment #1 from anlauf at gcc dot gnu.org ---
Confirmed to fail on 13-branch at r13-7813, but working at r13-8592.

Also 14-mainline is ok, so must have been fixed there and backported,
possibly as r13-7986.

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

* [Bug fortran/106317] deferred-length character array pointer in derived type
  2022-07-15 17:13 [Bug fortran/106317] New: deferred-length character array pointer in derived type clange001 at gmail dot com
  2024-04-07 20:01 ` [Bug fortran/106317] " anlauf at gcc dot gnu.org
@ 2024-05-14 20:06 ` anlauf at gcc dot gnu.org
  1 sibling, 0 replies; 3+ messages in thread
From: anlauf at gcc dot gnu.org @ 2024-05-14 20:06 UTC (permalink / raw)
  To: gcc-bugs

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

anlauf at gcc dot gnu.org changed:

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

--- Comment #2 from anlauf at gcc dot gnu.org ---
(In reply to anlauf from comment #1)
> Confirmed to fail on 13-branch at r13-7813, but working at r13-8592.
> 
> Also 14-mainline is ok, so must have been fixed there and backported,
> possibly as r13-7986.

Indeed a duplicate of 67740.  Thus fixed in 13.3 and later.

*** This bug has been marked as a duplicate of bug 67740 ***

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

end of thread, other threads:[~2024-05-14 20:06 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-07-15 17:13 [Bug fortran/106317] New: deferred-length character array pointer in derived type clange001 at gmail dot com
2024-04-07 20:01 ` [Bug fortran/106317] " anlauf at gcc dot gnu.org
2024-05-14 20:06 ` 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).