public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/44265] New: Link error with reference to parameter array in specification expression
@ 2010-05-25 2:00 ian_harvey at bigpond dot com
2010-05-25 9:50 ` [Bug fortran/44265] " burnus at gcc dot gnu dot org
0 siblings, 1 reply; 2+ messages in thread
From: ian_harvey at bigpond dot com @ 2010-05-25 2:00 UTC (permalink / raw)
To: gcc-bugs
The following program compiles successfully, but results in an undefined
reference to `___MOD_names' during linking. It compiles and links successfully
with g95 0.92! (May 31, 2009)and ifort 11.1.065.
Using gfortran built from svn trunk revision 159797. Command line was simply
"gfortran filename.f90". Some experimentation shows that the problem is
related to the use of an module procedure scoped array parameter in the
specification expression for the function result. The type of the parameter
array doesn't seem to matter.
MODULE Fruits
IMPLICIT NONE
PRIVATE
PUBLIC :: Get
CONTAINS
FUNCTION Get(i) RESULT(s)
CHARACTER(*), PARAMETER :: names(3) = [ &
'Apple ', &
'Orange ', &
'Mango ' ];
INTEGER, INTENT(IN) :: i
CHARACTER(LEN_TRIM(names(i))) :: s
!****
s = names(i)
END FUNCTION Get
END MODULE Fruits
PROGRAM WheresThatbLinkingConstantGone
USE Fruits
IMPLICIT NONE
!****
WRITE (*, "('Eat the tasty ',A)") Get(1)
END PROGRAM WheresThatbLinkingConstantGone
--
Summary: Link error with reference to parameter array in
specification expression
Product: gcc
Version: 4.6.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: fortran
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: ian_harvey at bigpond dot com
GCC build triplet: i686-pc-mingw32
GCC host triplet: i686-pc-mingw32
GCC target triplet: i686-pc-mingw32
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44265
^ permalink raw reply [flat|nested] 2+ messages in thread
* [Bug fortran/44265] Link error with reference to parameter array in specification expression
2010-05-25 2:00 [Bug fortran/44265] New: Link error with reference to parameter array in specification expression ian_harvey at bigpond dot com
@ 2010-05-25 9:50 ` burnus at gcc dot gnu dot org
0 siblings, 0 replies; 2+ messages in thread
From: burnus at gcc dot gnu dot org @ 2010-05-25 9:50 UTC (permalink / raw)
To: gcc-bugs
------- Comment #1 from burnus at gcc dot gnu dot org 2010-05-25 09:50 -------
CONFIRM
(No regression: GCC 4.1/4.2/4.3 reject the code ["names" invalid in expression]
while 4.4/4.5/4.6 show either the link error or ICE. Other compilers simply
work.)
One has the local parameter:
CHARACTER(*), PARAMETER :: names(3) = ...
And the characteristics of the result variable
INTEGER, INTENT(IN) :: i
CHARACTER(LEN_TRIM(names(i))) :: s
which depend on the argument. (While "len(names(i))" is constant,
"len_trim(names(i))" is not.)
Thus, I see two possibilities: Mark the return length (in .MOD) as unknown
(which g95 and NAG f95 seemingly do) - or to properly handle the PARAMETER.
Looking at gfortran's .mod file, one finds:
4 'names' '' 'names' 6 ((PARAMETER UNKNOWN-INTENT UNKNOWN-PROC UNKNOWN ...
Thus, the symbol is already saved.
* * *
Variant: If one adds a
subroutine test()
print *, get(1)
end subroutine test
in the module itself, one gets an ICE:
foo.f90:18:0: internal compiler error: in gfc_generate_function_code, at
fortran/trans-decl.c:4378
--
burnus at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |pault at gcc dot gnu dot org
Status|UNCONFIRMED |NEW
Ever Confirmed|0 |1
Keywords| |ice-on-valid-code, rejects-
| |valid
Last reconfirmed|0000-00-00 00:00:00 |2010-05-25 09:50:41
date| |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44265
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2010-05-25 9:50 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-05-25 2:00 [Bug fortran/44265] New: Link error with reference to parameter array in specification expression ian_harvey at bigpond dot com
2010-05-25 9:50 ` [Bug fortran/44265] " burnus at gcc dot gnu dot 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).