This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug fortran/46325] [4.6 Regression] gfortran.dg/char_initialiser_actual.f90 FAILs with -fstack-protector
- From: "burnus at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Thu, 11 Nov 2010 21:58:56 +0000
- Subject: [Bug fortran/46325] [4.6 Regression] gfortran.dg/char_initialiser_actual.f90 FAILs with -fstack-protector
- Auto-submitted: auto-generated
- References: <bug-46325-4@http.gcc.gnu.org/bugzilla/>
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46325
Tobias Burnus <burnus at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |burnus at gcc dot gnu.org
--- Comment #4 from Tobias Burnus <burnus at gcc dot gnu.org> 2010-11-11 21:58:42 UTC ---
(In reply to comment #2)
> If this is actually valid Fortran
Short answer: The reduced test program in comment 2 is invalid according to the
Fortran standard. Long answer below.
> program char_initialiser
> character*5, dimension(3) :: x
> character*5, dimension(:), pointer :: y
> x=(/"is Ja","ne Fo","nda "/)
So far so good. "y" is a pointer and "x" is a nonpointer, nontarget which thus
may not alias.
> y => pfoo ((/"is Ja","ne Fo","nda "/))
By itself, it looks valid.
> function pfoo(ch2)
> character*5, dimension(:), target :: ch2
> character*5, dimension(:), pointer :: pfoo
> pfoo => ch2
> end function pfoo
Also this function looks valid as "ch2" is a target (at least in the scope of
"pfoo"). However, as the actual argument associated with "pfoo" (namely "x") is
not a target, the pointer "pfoo" has the pointer associations status
"undefined" after "pfoo" -- that's still valid. Thus:
y => pfoo ((/"is Ja","ne Fo","nda "/))
is equivalent to
y => <undefined pointer>
However, the following line is invalid:
call afoo (y, x)
as the dummy arguments of "afoo" are not pointers and "y" has the status
undefined.
To put this in some legalize by quoting from Fortran 2008:
"12.5.2.4 Ordinary dummy variables" [...] "If the dummy argument has the TARGET
attribute and the effective argument does not have the TARGET attribute or is
an array section with a vector subscript, any pointers associated with the
dummy argument become undefined when execution of the procedure completes."
And: "7.1.9.2 Type, type parameters, and shape of a primary"
"If the pointer is not associated with a target, it may appear as a primary
only as an actual argument in a reference to a procedure whose corresponding
dummy argument is declared to be a pointer, or as the target in a pointer
assignment statement."