https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106692
Paul Thomas <pault at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |pault at gcc dot gnu.org --- Comment #8 from Paul Thomas <pault at gcc dot gnu.org> --- (In reply to anlauf from comment #5) > Just an observation: adding to subroutine shape_cray either > > save :: ptrzz > > or > > volatile :: ptrzz > > creates sufficient confusion in the middle-end that the code seems to work. > > (The code sample also works with Crayftn, whatever that means...) Hi Harald, Following your remarks, I tried setting the pointer decl tree static. That resulted in the test succeeding for -O but it crashed at higher levels of optimization. Treating the pointer as if it were volatile; ie. diff --git a/gcc/fortran/trans-decl.cc b/gcc/fortran/trans-decl.cc index 0b1474d7559..faa0e703321 100644 --- a/gcc/fortran/trans-decl.cc +++ b/gcc/fortran/trans-decl.cc @@ -747,7 +747,8 @@ gfc_finish_var_decl (tree decl, gfc_symbol * sym) TREE_STATIC (decl) = 1; /* Treat asynchronous variables the same as volatile, for now. */ - if (sym->attr.volatile_ || sym->attr.asynchronous) + if (sym->attr.volatile_ || sym->attr.asynchronous + || (sym->attr.cray_pointer && !sym->attr.in_common)) { TREE_THIS_VOLATILE (decl) = 1; TREE_SIDE_EFFECTS (decl) = 1; does the job at all levels of optimization. However, it does cause regressions in analyzer/malloc.f90 and analyzer/malloc_example.f90. The latter is interesting because the analyzer detects leaks, whereas valgrind says that the runtime is OK. Do we want to fix this, given Jakub and Tobias's remarks? Paul