Hide Forgot
Created attachment 534883 [details] Program to reproduce segmentation fault / internal compiler error Description of problem: Using a construct like the following: IF ( ANY( A == B ) ) THEN ... END IF will crash gfortran 4.6.1 if A and B are derived types and the == operator has been overloaded with a function that compares the two. Version-Release number of selected component (if applicable): GNU Fortran (GCC) 4.6.1 20110908 (Red Hat 4.6.1-9) How reproducible: Easily Steps to Reproduce: 1. Make a derived type with two integers bound to it 2. Define an elemental function that accepts two members of that derived type that compares both components and returns .TRUE. if they are the same and .FALSE. if either one is different 3. Define an overloaded == operator that uses this function 4. Write something like "if ( any(h == g) ) then ..." somewhere, where h is an array (rank 1 object) of the derived type and g is a rank-0 object ("scalar") of the same type. Actual results: internal compiler error: Segmentation fault Expected results: compiles as it would if h and g were integers instead of derived types Additional info: Attached example program (29 lines) reproduces the problem on my system.
Hi Karl, As we know Segmentation fault is due to some memory errors , i am unaware about FORTRAN but while going through the code i saw something, type (a), dimension(10) :: h //The dimension of array is specified type (a) :: g // but there is no memory allocation here would you please check this?
elemental function equal_a (x,y) result (same) + type (a), intent(in) :: x, y logical :: same if ( x%i == y%i .and. x%j == y%j ) then same = .TRUE. else same = .FALSE. end if end function equal_a changing class to type compiled the code without segmentation fault....
If using a polymorphic type here is wrong, the compiler should toss up an error (not segfault). I can see where it doesn't really make sense to use a polymorphic type for the comparison operator (==) here (good point), but there's still a bug in the compiler for this construct.
Yes, i think i get your point,and the gfortran updated to: GNU Fortran (GCC) 4.6.2 20111027 (Red Hat 4.6.2-1) please update your compiler, would you please send a feed back after updating your compiler , thanks for a fair report. -- Fedora Bugzappers volunteer triage team https://fedoraproject.org/wiki/BugZappers
Tracking this upstream.