Adapted from a test case from c.l.f, from James van Buskirk
:
$ cat foo.f90
program main
integer, parameter :: ipi = 1078530011
real pi
parameter(pi=transfer(ipi,pi))
real, parameter :: z = transfer(ipi,z)
real, parameter :: y = real(1,kind(y))
write(*,*) pi, z, y
end
$ gfortran -std=f95 -pedantic foo.f90
$ ./a.out
3.1415927 3.1415927 1.00000000
JvB's explanation:
# the second
# and third treat transfer as a specification inquiry even thought
# that is not permitted even in f03, and the fourth has that pesky
# REAL intrinsic, which is not an elemental function of type integer
# or character.
gfortran 4.2 still generates some error messages:
$ gfortran-4.2 foo.f90
foo.f90:4.29:
parameter(pi=transfer(ipi,pi))
1
Error: Parameter 'pi' at (1) has not been declared or is a variable, which does
not reduce to a constant expression
foo.f90:5.35:
real, parameter :: z = transfer(ipi,z)
1
Error: TRANSFER intrinsic not implemented for initialization at (1)
--
Summary: [4.3 Regression] accepts invalid initialization
expressions with -std=f95
Product: gcc
Version: 4.3.0
Status: UNCONFIRMED
Keywords: accepts-invalid, diagnostic
Severity: normal
Priority: P3
Component: fortran
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: tkoenig at gcc dot gnu dot org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34495