[Bug fortran/112459] gfortran -w option causes derived-type finalization at creation time

2023-12-16 Thread cvs-commit at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112459

--- Comment #4 from GCC Commits  ---
The master branch has been updated by Paul Thomas :

https://gcc.gnu.org/g:9a1105b770df9a9b485705398abbb74b5c487a25

commit r14-6621-g9a1105b770df9a9b485705398abbb74b5c487a25
Author: Paul Thomas 
Date:   Sat Dec 16 13:59:45 2023 +

Fortran: Prevent unwanted finalization with -w option [PR112459]

2023-12-16  Paul Thomas  

gcc/fortran
PR fortran/112459
* trans-array.cc (gfc_trans_array_constructor_value): Replace
gfc_notification_std with explicit logical expression that
selects F2003/2008 and excludes -std=default/gnu.
* trans-expr.cc (gfc_conv_expr): Ditto.

gcc/testsuite/
PR fortran/112459
* gfortran.dg/pr112459.f90: New test.

[Bug fortran/112459] gfortran -w option causes derived-type finalization at creation time

2023-11-11 Thread pault at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112459

--- Comment #3 from Paul Thomas  ---
Hi Sebastien,

I have posted the patch to the gfortran list. Hopefully, the bug will be fixed
this weekend.

Thanks for the report.

Paul

[Bug fortran/112459] gfortran -w option causes derived-type finalization at creation time

2023-11-09 Thread pault at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112459

Paul Thomas  changed:

   What|Removed |Added

   Last reconfirmed||2023-11-09
 Status|UNCONFIRMED |NEW
 Ever confirmed|0   |1
 Blocks||37336

--- Comment #2 from Paul Thomas  ---
It has been on my TODO list to partially revert the finalization of structure
and array constructors so that gfortran behaves like nagfor and only "knows"
about F2018. Finalization of constructors per se was removed in F2018 for very
good reasons!

I am still working on the CLASS variants of PR99065. Perhaps I should put that
on one side and clean up finalization?

@Sebastien - I will have to see what the -w switch does and why it should
affect the code behaviour. I can confirm the behaviour that you describe, as
Harald has already done. The F2003 and F2008 specific parts are blocked by:

if (!gfc_notification_std (GFC_STD_F2018_DEL) &&  Evidently switching off
the warnings with -w causes this to return true!

Cheers

Paul


Referenced Bugs:

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=37336
[Bug 37336] [F03] Finish derived-type finalization

[Bug fortran/112459] gfortran -w option causes derived-type finalization at creation time

2023-11-09 Thread anlauf at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112459

anlauf at gcc dot gnu.org changed:

   What|Removed |Added

 CC||pault at gcc dot gnu.org

--- Comment #1 from anlauf at gcc dot gnu.org ---
When I compile the code with -std=f2008, I get:

pr112459.f90:28:13:

   28 |   allocate(c)
  | 1
Warning: The structure constructor at (1) has been finalized. This feature was
removed by f08/0011. Use -std=f2018 or -std=gnu to eliminate the finalization.

It behaves as you expect if I specify -std=gnu or -std=f2018.

Trying several combinations, it appears the following variants work:

-std=gnu
-std=f2018
-std=f2018 -w

and these "fail":

-w
-std=f2008
-std=f2008 -w
-std=gnu -w

Note that default is -std=gnu .

Now I wonder how -w interferes with -std=gnu ...