program main
integer, dimension(3,4) :: A
integer, dimension(2) :: B = shape(A)
end program main
gives the following error on g95 v0.92 on Ubuntu 9.10 Netbook Remix:
integer, dimension(2) :: B = shape(A)
1
Error: Can't convert INTEGER(0) to INTEGER(4) at (1)
I have other systems with g95 v0.92 installed which don't fail, and
gfortran also gives no error. Any suggestions?
Graham
Also fails on my Win7 32bit PC. Puzzling why you have found that it
doesn't fail on other systems with g95. Silverfrost compiler also
fails with error ***Constant expression required. I think that the
instruction is not legal F95 because the initialization is a function
result, but I am not certain of this. If it is legal then there is a
bug in G95, if not there is a bug in gfortran. Writing it as
program main
integer, dimension(3,4) :: A
integer, dimension(2) :: B
B = shape(A)
end program main
works okay.
Jimmy.
I checked again with my Desktop 64-bit Ubuntu 9.04. It does pass, and
it's also g95 v0.92. Here's the entire output of "g95 -v" on that
machine:
Using built-in specs.
Target:
Configured with: ../configure
Thread model: posix
gcc version 4.0.3 (g95 0.92!) Nov 24 2008
And the result of "gcc -v"
...
gcc version 4.3.3 (Ubuntu 4.3.3-5ubuntu4)
...and here's the same from the failing Ubuntu Netbook Remix. "g95 -
v":
Using built-in specs.
Target:
Configured with: ../configure --enable-languages=c
Thread model: posix
gcc version 4.0.3 (g95 0.92!) Jun 24 2009
...and the result of "gcc -v"
...
gcc version 4.4.1 (Ubuntu 4.4.1-4ubuntu8)
I see that the g95 v0.92 dates are different. It may be worthwhile for
me to try and obtain the older (Nov 2008) version for the Netbook.
(Could this be a version 0.93.)
Graham
On Dec 29, 5:34 am, PGK <graham.k...@gmail.com> wrote:
> Looking at the standard, it seems that functions appearing within
> initialisation expressions must be elemental and intrinsic. "shape"
> then is, I think, non-elemental, so that's one result...
That's not the problem. Shape(A) is an inquiry intrinsic function.
That, with its argument A as given, is OK in this context by the F95
standard 7.1.6.1. I get the error with g95 on a machine on which g95 -
v says
Using built-in specs.
Target:
Configured with: ../configure
Thread model: posix
gcc version 4.0.3 (g95 0.92!) Jun 24 2009
and gcc -v says
Using built-in specs.
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --enable-languages=c,c+
+,fortran,objc,obj-c++,treelang --prefix=/usr --enable-shared --with-
system-zlib --libexecdir=/usr/lib --without-included-gettext --enable-
threads=posix --enable-nls --with-gxx-include-dir=/usr/include/c++/4.2
--program-suffix=-4.2 --enable-clocale=gnu --enable-libstdcxx-debug --
enable-objc-gc --enable-mpfr --enable-checking=release --build=x86_64-
linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu
Thread model: posix
gcc version 4.2.4 (Ubuntu 4.2.4-1ubuntu4)
Is the bug in g95 or gcc ?
John Harper