[Patch, Fortran] Add end-of-scope finalization (Part 2 of 2)

Tobias Burnus burnus@net-b.de
Wed Jun 26 10:02:00 GMT 2013


Dear Dominique,

Dominique Dhumieres wrote:
> Failures in 32 bit mode again!-(
> FAIL: gfortran.dg/finalize_18.f90  -O   scan-tree-dump-times original "y.cc._vptr->_final \\(&desc.5, \\(integer\\(kind=8\\)\\) y.cc._vptr->_size, 1\\);" 1

I will fix those before committal.

> /opt/gcc/work/gcc/testsuite/gfortran.dg/class_48.f90: In function '__final_test2_T.2138.constprop.0':
> /opt/gcc/work/gcc/testsuite/gfortran.dg/class_48.f90:39:0: warning: iteration 2147483648 invokes undefined behavior [-Waggressive-loop-optimizations]
>       class(t), allocatable :: a
>   ^

I have not fully understood why this happens. It seems to have something 
to do with cloning/const propagation. Looking at the original dump, the 
optimized dump at -O0, -O2 and -O3 - and at the FE code -, I believe the 
generated code is correct.

The cloning propagates the rank == 1 into the cloned finalizer, which 
permits to drastically simplify the scalarizer. That allows to remove 
one loop (the one which is warned about?) and to simplify another loop 
into a single trip.

Thus, my working hypothesis is that either the warning is wrong or that 
something goes wrong with the loop optimization, triggering the warning.

Tobiashhhhh



More information about the Fortran mailing list