https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66251

Joost VandeVondele <Joost.VandeVondele at mat dot ethz.ch> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |Joost.VandeVondele at mat dot 
ethz
                   |                            |.ch

--- Comment #5 from Joost VandeVondele <Joost.VandeVondele at mat dot ethz.ch> 
---
(In reply to Richard Biener from comment #2)
> I have a fix for the ICE:

thanks!

> but I'm not sure we create correct code here.  
> Joost - can you produce a runtime testcase that verifies correctness?

well spotted... the following fails with obviously wrong results:

> cat bug.f90
MODULE M1
CONTAINS
SUBROUTINE dbcsr_data_convert (s_data_c,t_data_z,n)
  COMPLEX(KIND=4), DIMENSION(:), POINTER :: s_data_c
  COMPLEX(KIND=8), DIMENSION(:), POINTER :: t_data_z
  t_data_z(1:n) = CMPLX(s_data_c(1:n), KIND=8)
END SUBROUTINE dbcsr_data_convert
END MODULE M1

USE M1
INTEGER :: n=2
COMPLEX(KIND=4), DIMENSION(:), POINTER :: s_data_c
COMPLEX(KIND=8), DIMENSION(:), POINTER :: t_data_z
REAL(KIND=8) :: diff
ALLOCATE(s_data_c(n),t_data_z(n))
s_data_c=(/(i,i=1,n)/)+(/(i,i=1,n)/)*(0,42)
call dbcsr_data_convert (s_data_c,t_data_z,n)
diff=ABS(t_data_z(n)-s_data_c(n))
IF (diff>2*EPSILON(1.0_4)) THEN
   write(6,*) s_data_c
   write(6,*) t_data_z
   CALL ABORT()
ENDIF

END 

> gfortran -O3 -march=native -fno-inline bug.f90 ; ./a.out
 (  1.00000000    ,  42.0000000    ) (  2.00000000    ,  84.0000000    )
 (  1.0000000000000000     ,  1.0242026242921894E-312) (  42.000000000000000   
 ,  0.0000000000000000     )

Program aborted. Backtrace:
#0  0x7F593AA0CC97
#1  0x7F593AA0DAD2
#2  0x7F593AADD128
#3  0x401233 in MAIN__ at bug.f90:?
Aborted

Reply via email to