Index: gcc/fortran/trans-decl.c =================================================================== --- gcc/fortran/trans-decl.c (revision 211315) +++ gcc/fortran/trans-decl.c (working copy) @@ -4278,8 +4278,8 @@ gfc_create_module_variable (gfc_symbol * } /* Don't generate variables from other modules. Variables from - COMMONs will already have been generated. */ - if (sym->attr.use_assoc || sym->attr.in_common) + COMMONs and Cray pointees will already have been generated. */ + if (sym->attr.use_assoc || sym->attr.in_common || sym->attr.cray_pointee) return; /* Equivalenced variables arrive here after creation. */ Index: gcc/testsuite/gfortran.dg/cray_pointers_10.f90 =================================================================== --- gcc/testsuite/gfortran.dg/cray_pointers_10.f90 (revision 0) +++ gcc/testsuite/gfortran.dg/cray_pointers_10.f90 (working copy) @@ -0,0 +1,18 @@ +! { dg-do run } +! { dg-options "-fcray-pointer" } +! +! PR fortran/45187 +! +module foo + implicit none + real :: a + pointer(c_a, a) +end module foo + +program test + use foo + real :: z + c_a = loc(z) + a = 42 + if (z /= 42) call abort +end program test