public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/100337] New: Should be able to pass non-present optional arguments to CO_BROADCAST
@ 2021-04-29 16:43 everythingfunctional at protonmail dot com
2021-05-21 8:22 ` [Bug fortran/100337] " vehre at gcc dot gnu.org
` (6 more replies)
0 siblings, 7 replies; 8+ messages in thread
From: everythingfunctional at protonmail dot com @ 2021-04-29 16:43 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100337
Bug ID: 100337
Summary: Should be able to pass non-present optional arguments
to CO_BROADCAST
Product: gcc
Version: 10.2.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: fortran
Assignee: unassigned at gcc dot gnu.org
Reporter: everythingfunctional at protonmail dot com
Target Milestone: ---
Attempting to write a CO_BROADCAST wrapper for a derived type, I found that
passing optional arguments to CO_BROADCAST caused a segfault if the arguments
were not present. This should be allowed. See the following minimal example
module iso_varying_string
implicit none
type :: varying_string
character(len=1), allocatable :: characters(:)
contains
procedure :: co_broadcast => co_broadcast_varying_string
end type
contains
subroutine co_broadcast_varying_string(a, source_image, stat, errmsg)
class(varying_string), intent(inout) :: a
integer, intent(in) :: source_image
integer, intent(out), optional :: stat
character(len=*), intent(inout), optional :: errmsg
integer :: string_length
if (this_image() == source_image) string_length = size(a%characters)
call co_broadcast(string_length, source_image, stat, errmsg)
if (present(stat)) then
if (stat /= 0) return
end if
if (this_image() /= source_image) then
allocate(a%characters(string_length))
end if
call co_broadcast(a%characters, source_image, stat, errmsg)
end subroutine
end module
program main
use iso_varying_string, only: varying_string
implicit none
character(len=*), parameter :: MESSAGE = "Hello, World!"
integer :: i
type(varying_string) :: the_string
if (this_image() == 1) the_string%characters = [(MESSAGE(i:i), i = 1,
len(MESSAGE))]
call the_string%co_broadcast(1)
print *, the_string%characters
end program
Compiling and executing with gfortran produces the following:
$ gfortran -fcoarray=single -g example.f90
$ ./a.out
Program received signal SIGSEGV: Segmentation fault - invalid memory reference.
Backtrace for this error:
#0 0x7fed85487d01 in ???
#1 0x7fed85486ed5 in ???
#2 0x7fed852be94f in ???
#3 0x55cd33d21683 in __iso_varying_string_MOD_co_broadcast_varying_string
at /home/brad/tmp/co_broadcast_optional/example.f90:20
#4 0x55cd33d21872 in MAIN__
at /home/brad/tmp/co_broadcast_optional/example.f90:43
#5 0x55cd33d21915 in main
at /home/brad/tmp/co_broadcast_optional/example.f90:35
zsh: segmentation fault (core dumped) ./a.out
Note that using opencoarrays this program works, as follows:
$ caf example.f90
$ cafrun -n 2 ./a.out
Hello, World!
Hello, World!
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug fortran/100337] Should be able to pass non-present optional arguments to CO_BROADCAST
2021-04-29 16:43 [Bug fortran/100337] New: Should be able to pass non-present optional arguments to CO_BROADCAST everythingfunctional at protonmail dot com
@ 2021-05-21 8:22 ` vehre at gcc dot gnu.org
2021-05-21 13:34 ` vehre at gcc dot gnu.org
` (5 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: vehre at gcc dot gnu.org @ 2021-05-21 8:22 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100337
Andre Vehreschild <vehre at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Assignee|unassigned at gcc dot gnu.org |vehre at gcc dot gnu.org
CC| |vehre at gcc dot gnu.org
Ever confirmed|0 |1
Last reconfirmed| |2021-05-21
Status|UNCONFIRMED |ASSIGNED
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug fortran/100337] Should be able to pass non-present optional arguments to CO_BROADCAST
2021-04-29 16:43 [Bug fortran/100337] New: Should be able to pass non-present optional arguments to CO_BROADCAST everythingfunctional at protonmail dot com
2021-05-21 8:22 ` [Bug fortran/100337] " vehre at gcc dot gnu.org
@ 2021-05-21 13:34 ` vehre at gcc dot gnu.org
2021-05-21 13:42 ` vehre at gcc dot gnu.org
` (4 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: vehre at gcc dot gnu.org @ 2021-05-21 13:34 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100337
--- Comment #1 from Andre Vehreschild <vehre at gcc dot gnu.org> ---
Created attachment 50853
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=50853&action=edit
Check for unset before assigning to stat.
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug fortran/100337] Should be able to pass non-present optional arguments to CO_BROADCAST
2021-04-29 16:43 [Bug fortran/100337] New: Should be able to pass non-present optional arguments to CO_BROADCAST everythingfunctional at protonmail dot com
2021-05-21 8:22 ` [Bug fortran/100337] " vehre at gcc dot gnu.org
2021-05-21 13:34 ` vehre at gcc dot gnu.org
@ 2021-05-21 13:42 ` vehre at gcc dot gnu.org
2021-06-23 8:17 ` cvs-commit at gcc dot gnu.org
` (3 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: vehre at gcc dot gnu.org @ 2021-05-21 13:42 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100337
Andre Vehreschild <vehre at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|ASSIGNED |WAITING
--- Comment #2 from Andre Vehreschild <vehre at gcc dot gnu.org> ---
Waiting for review
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug fortran/100337] Should be able to pass non-present optional arguments to CO_BROADCAST
2021-04-29 16:43 [Bug fortran/100337] New: Should be able to pass non-present optional arguments to CO_BROADCAST everythingfunctional at protonmail dot com
` (2 preceding siblings ...)
2021-05-21 13:42 ` vehre at gcc dot gnu.org
@ 2021-06-23 8:17 ` cvs-commit at gcc dot gnu.org
2021-06-23 8:24 ` vehre at gcc dot gnu.org
` (2 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2021-06-23 8:17 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100337
--- Comment #3 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Andre Vehreschild <vehre@gcc.gnu.org>:
https://gcc.gnu.org/g:da13e4ebebb07a47d5fb50eab8893f8fe38683df
commit r12-1741-gda13e4ebebb07a47d5fb50eab8893f8fe38683df
Author: Andre Vehreschild <vehre@gcc.gnu.org>
Date: Wed Jun 23 10:09:29 2021 +0200
fortran: Fix deref of optional in gen. code. [PR100337]
gcc/fortran/ChangeLog:
PR fortran/100337
* trans-intrinsic.c (conv_co_collective): Check stat for null ptr
before dereferrencing.
gcc/testsuite/ChangeLog:
PR fortran/100337
* gfortran.dg/coarray_collectives_17.f90: New test.
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug fortran/100337] Should be able to pass non-present optional arguments to CO_BROADCAST
2021-04-29 16:43 [Bug fortran/100337] New: Should be able to pass non-present optional arguments to CO_BROADCAST everythingfunctional at protonmail dot com
` (3 preceding siblings ...)
2021-06-23 8:17 ` cvs-commit at gcc dot gnu.org
@ 2021-06-23 8:24 ` vehre at gcc dot gnu.org
2022-02-14 15:49 ` cvs-commit at gcc dot gnu.org
2022-02-14 15:52 ` vehre at gcc dot gnu.org
6 siblings, 0 replies; 8+ messages in thread
From: vehre at gcc dot gnu.org @ 2021-06-23 8:24 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100337
--- Comment #4 from Andre Vehreschild <vehre at gcc dot gnu.org> ---
Waiting two weeks before backporting to gcc-11.
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug fortran/100337] Should be able to pass non-present optional arguments to CO_BROADCAST
2021-04-29 16:43 [Bug fortran/100337] New: Should be able to pass non-present optional arguments to CO_BROADCAST everythingfunctional at protonmail dot com
` (4 preceding siblings ...)
2021-06-23 8:24 ` vehre at gcc dot gnu.org
@ 2022-02-14 15:49 ` cvs-commit at gcc dot gnu.org
2022-02-14 15:52 ` vehre at gcc dot gnu.org
6 siblings, 0 replies; 8+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2022-02-14 15:49 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100337
--- Comment #5 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-11 branch has been updated by Andre Vehreschild
<vehre@gcc.gnu.org>:
https://gcc.gnu.org/g:ae57aae60d1be821feccb3160f8fdd5987ecba79
commit r11-9568-gae57aae60d1be821feccb3160f8fdd5987ecba79
Author: Andre Vehreschild <vehre@gcc.gnu.org>
Date: Mon Feb 14 16:47:16 2022 +0100
fortran: Fix deref of optional in gen. code. [PR100337, backport]
gcc/fortran/ChangeLog:
PR fortran/100337
Backport from master.
* trans-intrinsic.c (conv_co_collective): Check stat for null ptr
before dereferrencing.
gcc/testsuite/ChangeLog:
PR fortran/100337
* gfortran.dg/coarray_collectives_17.f90: New test.
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug fortran/100337] Should be able to pass non-present optional arguments to CO_BROADCAST
2021-04-29 16:43 [Bug fortran/100337] New: Should be able to pass non-present optional arguments to CO_BROADCAST everythingfunctional at protonmail dot com
` (5 preceding siblings ...)
2022-02-14 15:49 ` cvs-commit at gcc dot gnu.org
@ 2022-02-14 15:52 ` vehre at gcc dot gnu.org
6 siblings, 0 replies; 8+ messages in thread
From: vehre at gcc dot gnu.org @ 2022-02-14 15:52 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100337
Andre Vehreschild <vehre at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|WAITING |RESOLVED
Resolution|--- |FIXED
--- Comment #6 from Andre Vehreschild <vehre at gcc dot gnu.org> ---
Backported to gcc-11. Closing as fixed now.
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2022-02-14 15:52 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-29 16:43 [Bug fortran/100337] New: Should be able to pass non-present optional arguments to CO_BROADCAST everythingfunctional at protonmail dot com
2021-05-21 8:22 ` [Bug fortran/100337] " vehre at gcc dot gnu.org
2021-05-21 13:34 ` vehre at gcc dot gnu.org
2021-05-21 13:42 ` vehre at gcc dot gnu.org
2021-06-23 8:17 ` cvs-commit at gcc dot gnu.org
2021-06-23 8:24 ` vehre at gcc dot gnu.org
2022-02-14 15:49 ` cvs-commit at gcc dot gnu.org
2022-02-14 15:52 ` vehre 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).