[Bug fortran/52921] New: Memory errors when compiled with -fstrict-overflow flag
alipasha.celeris at gmail dot com
gcc-bugzilla@gcc.gnu.org
Tue Apr 10 02:13:00 GMT 2012
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52921
Bug #: 52921
Summary: Memory errors when compiled with -fstrict-overflow
flag
Classification: Unclassified
Product: gcc
Version: 4.8.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: fortran
AssignedTo: unassigned@gcc.gnu.org
ReportedBy: alipasha.celeris@gmail.com
The following test code generates memory errors (valgrind : "Conditional jump
or move depends on uninitialised value(s)") when assigning the values to %CMP
components without allocating it first, if it is compiled with flag
-fstrict-overflow.
PROGRAM QUICK_TEST
TYPE COMP
INTEGER, ALLOCATABLE :: CMP(:)
END TYPE COMP
TYPE COMP_ARRAY
TYPE (COMP), ALLOCATABLE :: ARR(:)
END TYPE COMP_ARRAY
INTEGER :: I
TYPE (COMP_ARRAY), TARGET :: MY_ARR
READ *, I
ALLOCATE (MY_ARR%ARR(I))
MY_ARR%ARR(I)%CMP = [1, 2]
END PROGRAM QUICK_TEST
However, if "READ *, I" is replaced with "I = 10", i.e. allocation size and the
array index are known at compile time, then no memory errors are generated.
Furthermore, this flag is included in -O3 optimization flag, but it is not
shown when compiling with -Q --help=optimizers .
More information about the Gcc-bugs
mailing list