https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69298
Paul Thomas <pault at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |pault at gcc dot gnu.org --- Comment #4 from Paul Thomas <pault at gcc dot gnu.org> --- (In reply to Dominique d'Humieres from comment #3) > > Created attachment 37448 [details] > > Self-contained variant > > With n=3, the output of the attached test is > > Initialising stuff_type 4 > Finalising stuff_type 0 > ... > --- > Initialising test_type > Initialising stuff_type 4 > Finalising stuff_type 0 > Copy initialiser 4 4 > Initialising stuff_type 1 > Finalising stuff_type 0 > Copy initialiser 1 1 > Initialising stuff_type 2 > Finalising stuff_type 0 > Copy initialiser 2 2 > Initialising stuff_type 3 > Finalising stuff_type 0 > Copy initialiser 3 3 > Finalising stuff_type 4 > Copy initialiser 4 4 > thing 10 > Finalising stuff_type 4 > > Program received signal SIGSEGV: Segmentation fault - invalid memory > reference. > > Changing 'n' to 2 or 4, gives respectively > > ... > --- > Initialising test_type > Initialising stuff_type 4 > Finalising stuff_type 1342972320 > Copy initialiser 4 4 > Initialising stuff_type 1 > Finalising stuff_type 32767 > Copy initialiser 1 1 > Initialising stuff_type 2 > Finalising stuff_type 263453344 > Copy initialiser 2 2 > Finalising stuff_type 4 > Copy initialiser 4 4 > thing 7 > Finalising stuff_type 4 > > Program received signal SIGSEGV: Segmentation fault - invalid memory > reference. > > and > > ... > Initialising test_type > Initialising stuff_type 4 > Finalising stuff_type 107478528 > Copy initialiser 4 4 > Initialising stuff_type 1 > Finalising stuff_type 1 > Copy initialiser 1 1 > Initialising stuff_type 2 > Finalising stuff_type 5120 > Copy initialiser 2 2 > Initialising stuff_type 3 > Finalising stuff_type 0 > Copy initialiser 3 3 > Initialising stuff_type 4 > Finalising stuff_type 1501114256 > Copy initialiser 4 4 > Finalising stuff_type 4 > Copy initialiser 4 4 > thing 14 > Finalising stuff_type 4 > > where the nonzero values changed between different runs. For the record, since I have spent an hour or two investigating this tonight: __final_test_mod_Test_type has, towards the end.... { struct array0_stuff_type desc.32; desc.32.dtype = 296; desc.32.data = (void * restrict) &ptr2->thing; __final_stuff_mod_Stuff_type (&desc.32); } { struct array1_stuff_type parm.33; parm.33.dtype = 297; parm.33.dim[0].lbound = 1; parm.33.dim[0].ubound = 3; parm.33.dim[0].stride = 1; parm.33.data = (void *) &ptr2->things[0]; parm.33.offset = -1; __final_stuff_mod_Stuff_type (&parm.33); } whereas the prototype for the 'stuff' finalization is __final_stuff_mod_Stuff_type (struct array7_stuff_type & restrict array, integer(kind=8) byte_stride, logical(kind=1) fini_coarray) That is to say that two actual arguments are missing. Since this contains if (byte_stride == 4) { { static integer(kind=8) C.3513 = 4; stuff_1d_finaliser ((struct array7_stuff_type *) array, &C.3513); } } It seems difficult to understand how stuff_1d_finaliser is getting called at all! I'll come back to this when I can. Paul