From: Daniel on
Hello everyone,

I am getting different results for the following seemingly simple
program using different compilers:

program test

implicit none
character (2), dimension (2), parameter :: list = (/'ab', 'ba'/)
integer :: i

i = 1
write (*, *) list (:) (1 : 1) == list (1) (i : i)

end program test

Using gcc (gcc version 4.3.3 20080904 (prerelease)) I get:
F F
Using g95 (gcc version 4.0.3 (g95 0.91!) Sep 24 2008) I get:
T F

The output from g95 is what I would expect. Is this a bug in gcc? Or is
my program incorrect, producing arbitrary output?

Daniel
From: Tobias Burnus on
On 05/26/2010 05:01 PM, Daniel wrote:
> I am getting different results for the following seemingly simple
> program using different compilers:
[...]

The program looks OK.

> Using gcc (gcc version 4.3.3 20080904 (prerelease)) I get:
> F F
> Using g95 (gcc version 4.0.3 (g95 0.91!) Sep 24 2008) I get:
> T F
> The output from g95 is what I would expect. Is this a bug in gcc? Or is
> my program incorrect, producing arbitrary output?

However, I tried your program with gfortran of GCC 4.1.2, 4.2.1, 4.3.4,
4.4.0, 4.5.0, and 4.6. Result: All print "T F".

One reason might be that your nightly experimental build of 4.3.3
2008-09-04 has a bug* - or it might be due to a certain combination of
compile-time options. Could you try a newer GCC version?

And, can you tell the system ("target" line printed by "gfortran -v")
and the compiler options you have used?

Tobias

(* Sometimes, bugs creep into the program (called "regression" in this
case); usually they are quickly fixed, but it can happen that the builds
are broken for a few weeks until someone realizes and fixes the problem.
That happens very rarely - especially on release branches [in your case:
3.3.2 -> 3.3.3], but might have happened in your case.)
From: Daniel on
Tobias Burnus wrote:
[...]

> The program looks OK.
>
> However, I tried your program with gfortran of GCC 4.1.2, 4.2.1,
> 4.3.4, 4.4.0, 4.5.0, and 4.6. Result: All print "T F".

So, it seems it is just my version giving wrong results.

> One reason might be that your nightly experimental build of 4.3.3
> 2008-09-04 has a bug* - or it might be due to a certain combination of
> compile-time options. Could you try a newer GCC version?

The version I am using is the one that was provided as a package with
FreeBSD 6.4-RELEASE (gcc-4.3.20080904). I never bothered upgrading; if
it works, don't break it.

> And, can you tell the system ("target" line printed by "gfortran -v")
> and the compiler options you have used?

Output from "gfortran -v":
Using built-in specs.
Target: i386-portbld-freebsd6.4
Configured
with: ./..//gcc-4.3-20080904/configure --disable-nls --with-system-zlib
--with-libiconv-prefix=/usr/local --with-gmp=/usr/local --program-suffix=43
--libdir=/usr/local/lib/gcc-4.3.3
--with-gxx-include-dir=/usr/local/lib/gcc-4.3.3/include/c++/ --disable-rpath
--prefix=/usr/local --mandir=/usr/local/man --infodir=/usr/local/info/gcc43
--build=i386-portbld-freebsd6.4 Thread model: posix
gcc version 4.3.3 20080904 (prerelease) (GCC)

Compiler options: -Wall -std=f95 -pedantic
Compilation gives no errors or warnings.

> (* Sometimes, bugs creep into the program (called "regression" in this
> case); usually they are quickly fixed, but it can happen that the
> builds are broken for a few weeks until someone realizes and fixes the
> problem. That happens very rarely - especially on release branches [in
> your case: 3.3.2 -> 3.3.3], but might have happened in your case.)

I was mainly interested in finding out if my little program was correct.
Since this seems to be the case, I just have to upgrade my compiler.
Thanks a lot for your response.

Daniel
 | 
Pages: 1
Prev: Fortran Basics
Next: getting the gap right