https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86828
Bug ID: 86828 Summary: [6/7 Regression] wrong-code bug with "-march=knl -Ofast" (invalid memory reference) Product: gcc Version: 8.2.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: target Assignee: unassigned at gcc dot gnu.org Reporter: janus at gcc dot gnu.org Target Milestone: --- Fortran test case: program knl_bug implicit none integer, parameter :: NN = 32 type tList integer, dimension(:), allocatable :: list end type integer, dimension(1:100) :: Y = 0 type(tList) :: nb allocate(nb%list(1:NN), source = 1) call s(nb) contains subroutine s(n) type(tList), intent(in) :: n integer, dimension(1:NN) :: liKOB liKOB = Y(n%list) print *,liKOB end subroutine end Compiling this with "gfortran -march=knl -Ofast -g", and then running the executable, I get: $ ./a.out Program received signal SIGSEGV: Segmentation fault - invalid memory reference. Backtrace for this error: #0 0x7f9d495c42da in ??? #1 0x7f9d495c3503 in ??? #2 0x7f9d491f6f1f in ??? #3 0x563dd9a3dd7f in s at test.f90:26 #4 0x563dd9a3da9a in knl_bug at test.f90:17 #5 0x563dd9a3da9a in main at test.f90:17 Segmentation fault (core dumped) I see this happening with: gcc version 6.4.0 20180727 (Ubuntu 6.4.0-19ubuntu1~18.04) gcc version 7.3.0 (Ubuntu 7.3.0-27ubuntu1~18.04) but not with: gcc version 5.5.0 20171010 (Ubuntu 5.5.0-12ubuntu1) gcc version 8.2.0 (Ubuntu 8.2.0-1ubuntu2~18.04) gcc version 9.0.0 20180730 (experimental) [trunk revision 263059] (GCC) Note that the segfault also happens with -march=skylake-avx512 (which is not available with gcc 5). Similar to PR 86735. The CPU where I found this is an Intel(R) Core(TM) i9-7980XE.