public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "burnus at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug fortran/65086] New: Segfault: Invalid copy-out of temporary as argument is in read-only memory
Date: Tue, 17 Feb 2015 07:58:00 -0000 [thread overview]
Message-ID: <bug-65086-4@http.gcc.gnu.org/bugzilla/> (raw)
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65086
Bug ID: 65086
Summary: Segfault: Invalid copy-out of temporary as argument is
in read-only memory
Product: gcc
Version: 5.0
Status: UNCONFIRMED
Keywords: wrong-code
Severity: normal
Priority: P3
Component: fortran
Assignee: unassigned at gcc dot gnu.org
Reporter: burnus at gcc dot gnu.org
>From James Van Buskirk's example in the comp.lang.fortran thread "Is INTENT
(IN) ever used to control code generation?" /
https://groups.google.com/d/msg/comp.lang.fortran/nzq3Sad_zQE/APiZzlGdNPQJ
The following program segfaults at run time, unless INTENT(IN) is specified for
sub4. The problem is the copy-out part as the original variable is in read-only
memory.
"Both gfortran and ifort throw an error at runtime for the above program with
the INTENT(IN) statements commented out, but ifort runs to completion if either
or both of them are in effect whereas gfortran only works if the INTENT(IN)
statement in subroutine sub4 is in effect."
And:
"But as the standard is written it seems the Fortran processor has to do this
comparison before it can copy out, which seems absolutely horrible to me,
[...]"
Bob replies: "Why does it seem horrible? Oracle Solaris Studio Fortran uses
this implementation."
module mod1
implicit none
character(*), parameter :: x = 'This is a constant string.'
end module mod1
module mod2
implicit none
contains
subroutine sub1(x)
character(*) x
call sub2(x,len(x))
end subroutine sub1
subroutine sub2(x,size)
integer size
character x(size)
call sub3(x)
end subroutine sub2
subroutine sub3(x)
character x(:)
!INTENT(IN) :: x
call sub4(x(1::2))
end subroutine sub3
subroutine sub4(x)
!INTENT(IN) :: x ! REQUIRED
character x(*)
end subroutine sub4
end module mod2
program main
use mod1
use mod2
implicit none
write(*,'(a)') x
call sub1(x)
write(*,'(a)') x
end program main
next reply other threads:[~2015-02-17 7:58 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-02-17 7:58 burnus at gcc dot gnu.org [this message]
2015-09-08 11:33 ` [Bug fortran/65086] " dominiq at lps dot ens.fr
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=bug-65086-4@http.gcc.gnu.org/bugzilla/ \
--to=gcc-bugzilla@gcc.gnu.org \
--cc=gcc-bugs@gcc.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).