This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug fortran/32140] New: wrong code
- From: "jv244 at cam dot ac dot uk" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 29 May 2007 15:03:22 -0000
- Subject: [Bug fortran/32140] New: wrong code
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
The following (reduced from CP2K, PR 29975) generates wrong code with gfortran
(gcc version 4.3.0 20070526)
MODULE TEST
CONTAINS
PURE FUNCTION s2a_3(s1,s2,s3) RESULT(a)
CHARACTER(LEN=*), INTENT(IN) :: s1, s2, s3
CHARACTER(LEN=4), DIMENSION(3) :: a
a(1)=s1; a(2)=s2; a(3)=s3
END FUNCTION
END MODULE
USE TEST
write(6,*) s2a_3("a","bb","ccc")
END
gfortran -O0 test.f90
> ./a.out
a bb ccc
> gfortran -O2 test.f90
> ./a.out
abb ccc
the latter case also shows:
==21268== Syscall param write(buf) points to uninitialised byte(s)
==21268== at 0x4FF9CB0: __write_nocancel (in /lib64/libc-2.4.so)
==21268== by 0x4BB8E10: do_write (unix.c:336)
==21268== by 0x4BB8EB1: fd_flush (unix.c:386)
==21268== by 0x4BB9AE7: fd_write (unix.c:761)
==21268== by 0x4BB65E5: _gfortrani_next_record (transfer.c:2526)
==21268== by 0x4BB69F5: finalize_transfer (transfer.c:2663)
==21268== by 0x4BB6A38: _gfortran_st_write_done (transfer.c:2801)
==21268== by 0x40090D: MAIN__ (in /users/vondele/g95/a.out)
==21268== by 0x400AEB: main (fmain.c:22)
==21268== Address 0x517A3CF is 151 bytes inside a block of size 8,344 alloc'd
==21268== at 0x4A20A56: malloc (vg_replace_malloc.c:149)
==21268== by 0x4B39518: _gfortrani_get_mem (memory.c:53)
==21268== by 0x4BB9879: fd_to_stream (unix.c:1043)
==21268== by 0x4BB86BB: _gfortrani_init_units (unit.c:515)
==21268== by 0x4B39267: init (main.c:152)
==21268== by 0x4BC8B61: (within
/data/vondele/gcc_trunk/build/lib64/libgfortran.so.3.0.0)
==21268== by 0x4B35F8A: (within
/data/vondele/gcc_trunk/build/lib64/libgfortran.so.3.0.0)
--
Summary: wrong code
Product: gcc
Version: 4.3.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: fortran
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: jv244 at cam dot ac dot uk
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=32140