[Bug fortran/58171] New: Incorrect error message on invalid code when using class constructor
abensonca at gmail dot com
gcc-bugzilla@gcc.gnu.org
Fri Aug 16 00:01:00 GMT 2013
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58171
Bug ID: 58171
Summary: Incorrect error message on invalid code when using
class constructor
Product: gcc
Version: 4.9.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: fortran
Assignee: unassigned at gcc dot gnu.org
Reporter: abensonca at gmail dot com
The following code leads to an incorrect error message from the compiler using
gfortran 4.9.0 (r201758):
module ct
type :: cps
private
double precision :: aa ! Removing this line leads to a more meaningful
error message from the compiler.
contains
end type cps
interface cps
module procedure newCps
end interface cps
contains
function newCps(a,b)
implicit none
type(cps) :: newCps
double precision, intent(in) :: a,b
return
end function newCps
end module ct
program bug
use ct
implicit none
type(cps) :: c
c=cps(0.27d0) !,0.13d0) ! Passing two arguments (as expected) results in
successful compile.
end program bug
$ gfortran -v
Using built-in specs.
COLLECT_GCC=/opt/gcc-trunk/bin/gfortran
COLLECT_LTO_WRAPPER=/opt/gcc-trunk/libexec/gcc/x86_64-unknown-linux-gnu/4.9.0/lto-wrapper
Target: x86_64-unknown-linux-gnu
Configured with: ../gcc-trunk/configure --prefix=/opt/gcc-trunk
--enable-languages=c,c++,fortran --disable-multilib
Thread model: posix
gcc version 4.9.0 20130808 (experimental) (GCC)
$ gfortran bug.F90 -o bug.exe
bug.F90:22.4:
c=cps(0.27d0) !,0.13d0) ! Passing two arguments (as expected) results in
successful compile.
1
Error: Component 'aa' at (1) is a PRIVATE component of 'cps'
The code is invalid - the class constructor requires two arguments - but the
error message doesn't reflect this. Passing two arguments to the constructor
results in a successful compile.
If I remove the "aa" variable from the cps type then the error message is more
useful:
$ gfortran bug.F90 -o bug.exe
bug.F90:22.8:
c=cps(0.27d0) !,0.13d0) ! Passing two arguments (as expected) results in
successful compile.
1
Error: Too many components in structure constructor at (1)!
but still incorrect - it should be "Too few components in structure
constructor", not "Too many".
More information about the Gcc-bugs
mailing list