This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug fortran/32140] [4.3 Regression] Miscompilation with -O1



------- Comment #10 from jv244 at cam dot ac dot uk  2007-06-15 14:43 -------
The segfault is still happening with today's code. This is the simplest case I
find to trigger it. 

MODULE TEST
CONTAINS
FUNCTION s2a_3(s1) RESULT(a)
    CHARACTER(LEN=*), INTENT(IN)             :: s1
    CHARACTER(LEN=1000) :: a(3)
    a(1)=s1
END FUNCTION
END MODULE

USE TEST
character(LEN=1000) :: b(3)
b=s2a_3(REPEAT("1",101))
write(6,*) b(1)
END

The point where things segfault is the assignment a(1)=s1, and in particular
the  corresponding memset (which adds blanks to the rest of the string). This
memset much be getting a wrong pointer to start with, according to valgrind:

==23016== Invalid write of size 1
==23016==    at 0x4A1AAF0: memset (mc_replace_strmem.c:490)
==23016==    by 0x400A4D: __test_MOD_s2a_3 (test2.f90:6)
==23016==    by 0x40098B: MAIN__ (test2.f90:12)
==23016==    by 0x400A8B: main (fmain.c:22)
==23016==  Address 0x7FF017FA8 is not stack'd, malloc'd or (recently) free'd

the bug only happens if a is at the same time
1) a function result
2) an array
3) of character variables with a len known at compile time.

in the dump tree original, the corresponding memset line looks like:

__builtin_memset (&(*__result.0)[NON_LVALUE_EXPR <stride.0> + offset.1] + (char
*) (int8) D.1374, 32, 1000 - (int8) D.1374);

but I can't see how I could debug further.... pretty please, can somebody look
into that... I'd like to be able to test all the stuff that went in since the
bug was opened a few weeks ago.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=32140


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]