public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/100860] New: class(*) type is (character(*)) produces a segmentation fault when run
@ 2021-06-01 17:39 thomas.robinson at noaa dot gov
2021-06-01 18:19 ` [Bug fortran/100860] " anlauf at gcc dot gnu.org
` (3 more replies)
0 siblings, 4 replies; 5+ messages in thread
From: thomas.robinson at noaa dot gov @ 2021-06-01 17:39 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100860
Bug ID: 100860
Summary: class(*) type is (character(*)) produces a
segmentation fault when run
Product: gcc
Version: 11.1.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: fortran
Assignee: unassigned at gcc dot gnu.org
Reporter: thomas.robinson at noaa dot gov
Target Milestone: ---
When a string is passed as an argument to a subroutine where the argument is
`class(*)`, there is a seg fault when the type is selected. Other types seem
to be working.
Previous versions of gfortran have no problem compiling and running this simple
program. I think the code is correct. It seems to be gcc 11 that has an
issue.
Here is some test code:
module ctest
contains
subroutine sub (carg, slen)
class(*), intent (in) :: carg
integer, optional, intent (in) :: slen
select type (carg)
type is (character(*))
if (.not.present(slen)) then
write (6,*) "This is an error dealing with a string"
else
write (6,*) "string length is ",slen
write (6,*) "String is ",carg(1:slen)
endif
type is (integer)
write (6,*) "Integer type is ", carg
type is (real)
write (6,*) "Real type is ", carg
class default
write (6,*) "Not the right type"
end select
end subroutine sub
end module ctest
program test
use ctest
character (len=10) :: c10
character (len=:), allocatable :: sall
integer :: i=100
real :: r = 999.9
logical :: l = .true.
call sub (r)
call sub (i)
call sub (l)
c10="12345"
allocate(character (len=i) :: sall)
sall = "87654321"
! write (6,*) "c10=",trim(c10),"::LEN=",len_trim(c10)
! call sub(trim(c10), len_trim(c10))
write (6,*) "sall=",trim(sall),"::LEN=",len_trim(sall)
call sub(trim(sall),len_trim(sall))
end program test
Here is the output
Real type is 999.900024
Integer type is 100
Not the right type
sall=87654321::LEN= 8
Program received signal SIGSEGV: Segmentation fault - invalid memory reference.
I tried with heap and stack strings, and both fail (you can see I have the
first one commented out). Please let me know if there's any more information
you need.
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug fortran/100860] class(*) type is (character(*)) produces a segmentation fault when run
2021-06-01 17:39 [Bug fortran/100860] New: class(*) type is (character(*)) produces a segmentation fault when run thomas.robinson at noaa dot gov
@ 2021-06-01 18:19 ` anlauf at gcc dot gnu.org
2021-06-01 18:38 ` dominiq at lps dot ens.fr
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: anlauf at gcc dot gnu.org @ 2021-06-01 18:19 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100860
anlauf at gcc dot gnu.org changed:
What |Removed |Added
----------------------------------------------------------------------------
Last reconfirmed| |2021-06-01
Status|UNCONFIRMED |WAITING
Ever confirmed|0 |1
--- Comment #1 from anlauf at gcc dot gnu.org ---
Possibly related to pr100551, which was fixed after the 11.1 release.
I do not see the issue with the current mainline or 11-branch version.
Can you please check?
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug fortran/100860] class(*) type is (character(*)) produces a segmentation fault when run
2021-06-01 17:39 [Bug fortran/100860] New: class(*) type is (character(*)) produces a segmentation fault when run thomas.robinson at noaa dot gov
2021-06-01 18:19 ` [Bug fortran/100860] " anlauf at gcc dot gnu.org
@ 2021-06-01 18:38 ` dominiq at lps dot ens.fr
2021-06-02 13:14 ` thomas.robinson at noaa dot gov
2021-06-02 13:16 ` thomas.robinson at noaa dot gov
3 siblings, 0 replies; 5+ messages in thread
From: dominiq at lps dot ens.fr @ 2021-06-01 18:38 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100860
--- Comment #2 from Dominique d'Humieres <dominiq at lps dot ens.fr> ---
WORKSFORME from GCC7 up to trunk.
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug fortran/100860] class(*) type is (character(*)) produces a segmentation fault when run
2021-06-01 17:39 [Bug fortran/100860] New: class(*) type is (character(*)) produces a segmentation fault when run thomas.robinson at noaa dot gov
2021-06-01 18:19 ` [Bug fortran/100860] " anlauf at gcc dot gnu.org
2021-06-01 18:38 ` dominiq at lps dot ens.fr
@ 2021-06-02 13:14 ` thomas.robinson at noaa dot gov
2021-06-02 13:16 ` thomas.robinson at noaa dot gov
3 siblings, 0 replies; 5+ messages in thread
From: thomas.robinson at noaa dot gov @ 2021-06-02 13:14 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100860
--- Comment #3 from Tom Robinson <thomas.robinson at noaa dot gov> ---
I tried with the main (12.0.0) and this code ran. I will try it in with our
main codebase to confirm it works there too.
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug fortran/100860] class(*) type is (character(*)) produces a segmentation fault when run
2021-06-01 17:39 [Bug fortran/100860] New: class(*) type is (character(*)) produces a segmentation fault when run thomas.robinson at noaa dot gov
` (2 preceding siblings ...)
2021-06-02 13:14 ` thomas.robinson at noaa dot gov
@ 2021-06-02 13:16 ` thomas.robinson at noaa dot gov
3 siblings, 0 replies; 5+ messages in thread
From: thomas.robinson at noaa dot gov @ 2021-06-02 13:16 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100860
Tom Robinson <thomas.robinson at noaa dot gov> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|WAITING |RESOLVED
Resolution|--- |FIXED
--- Comment #4 from Tom Robinson <thomas.robinson at noaa dot gov> ---
Actually, it looks like someone else saw this bug report and tested the code.
They reported it worked. Thanks.
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2021-06-02 13:16 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-01 17:39 [Bug fortran/100860] New: class(*) type is (character(*)) produces a segmentation fault when run thomas.robinson at noaa dot gov
2021-06-01 18:19 ` [Bug fortran/100860] " anlauf at gcc dot gnu.org
2021-06-01 18:38 ` dominiq at lps dot ens.fr
2021-06-02 13:14 ` thomas.robinson at noaa dot gov
2021-06-02 13:16 ` thomas.robinson at noaa dot gov
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).