public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/105542] New: [F03] Orthogonal standard-conforming type finalization tests
@ 2022-05-10  5:14 damian at archaeologic dot codes
  2022-05-11  3:01 ` [Bug fortran/105542] " jvdelisle at gcc dot gnu.org
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: damian at archaeologic dot codes @ 2022-05-10  5:14 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105542

            Bug ID: 105542
           Summary: [F03] Orthogonal standard-conforming type finalization
                    tests
           Product: gcc
           Version: 12.1.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
          Assignee: unassigned at gcc dot gnu.org
          Reporter: damian at archaeologic dot codes
  Target Milestone: ---

In case it's useful to gfortran developers, the Reference-Counter repository
(https://github.com/sourceryinstitute/reference-counter) contains a
test/compiler_test.f90 file that separately tests each of the scenarios in
which Fortran 2018 clause 7.5.6.3 requires type finalization to occur.  One
function tests each scenario.  A comment near the top of each such function
cites the paragraph number of the corresponding requirement.  To download and
run the tests on macOS or Linux with gfortran 12.1.0 and the Fortran Package
Manager (fpm) already installed, execute the following commands:

git clone https://github.com/sourceryinstitute/reference-counter
cd reference-counter
fpm test

for which the trailing output is


Running Tests

Test that
    The compiler
        finalizes a non-allocatable object on the LHS of an intrinsic
assignment
        finalizes an allocated allocatable LHS of an intrinsic assignment
        finalizes a target when the associated pointer is deallocated
        finalizes an object upon explicit deallocation
        finalizes a non-pointer non-allocatable array object at the END
statement
        finalizes a non-pointer non-allocatable object at the end of a block
construct
        finalizes a function reference on the RHS of an intrinsic assignment
        finalizes a specification expression function result
        finalizes an intent(out) derived type dummy argument
        finalizes an allocatable component object
    A ref_reference
        does not leak when constructed, assigned, and then explicitly freed

A total of 11 test cases

Failed
Took 1.94e-4 seconds

Test that
    The compiler
        finalizes a non-allocatable object on the LHS of an intrinsic
assignment
            Expected
                    |1|
                but got
                    |0|
        finalizes an allocated allocatable LHS of an intrinsic assignment
            Expected
                    |1|
                but got
                    |0|
        finalizes a function reference on the RHS of an intrinsic assignment
            Expected
                    |1|
                but got
                    |0|
        finalizes a specification expression function result
            Expected
                    |1|
                but got
                    |0|

4 of 11 cases failed
4 of 11 assertions failed

STOP 1
<ERROR> Execution failed for object " reference-counter-test "
<ERROR>*cmd_run*:stopping due to failed executions
STOP 1

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug fortran/105542] [F03] Orthogonal standard-conforming type finalization tests
  2022-05-10  5:14 [Bug fortran/105542] New: [F03] Orthogonal standard-conforming type finalization tests damian at archaeologic dot codes
@ 2022-05-11  3:01 ` jvdelisle at gcc dot gnu.org
  2022-05-11  3:11 ` damian at archaeologic dot codes
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: jvdelisle at gcc dot gnu.org @ 2022-05-11  3:01 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105542

Jerry DeLisle <jvdelisle at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jvdelisle at gcc dot gnu.org

--- Comment #1 from Jerry DeLisle <jvdelisle at gcc dot gnu.org> ---
Yes, it is always usefule to have tests available.

I cloned the repository.

fpm build is happy.

$ fpm test
compiler_test.f90                      done.
usage_test.f90                         done.
main.f90                               done.
reference-counter-test                 done.
[100%] Project compiled successfully.
Running Tests

Test that
    The compiler
        finalizes a non-allocatable object on the LHS of an intrinsic
assignment
        finalizes an allocated allocatable LHS of an intrinsic assignment
        finalizes a target when the associated pointer is deallocated
        finalizes an object upon explicit deallocation
        finalizes a non-pointer non-allocatable array object at the END
statement
        finalizes a non-pointer non-allocatable object at the end of a block
construct
        finalizes a function reference on the RHS of an intrinsic assignment
        finalizes a specification expression function result
        finalizes an intent(out) derived type dummy argument
        finalizes an allocatable component object
    Using a reference-counted object
        creates a resource when constructed
        removes the resource when it goes out of scope
        a copy points to the same resource

A total of 13 test cases

At line 42 of file test/usage_test.f90
Fortran runtime error: Attempt to DEALLOCATE unallocated 'the_resource'
<ERROR> Execution failed for object " reference-counter-test "
<ERROR>*cmd_run*:stopping due to failed executions
STOP 1

Am I missing a step? This is with gfortran 12.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug fortran/105542] [F03] Orthogonal standard-conforming type finalization tests
  2022-05-10  5:14 [Bug fortran/105542] New: [F03] Orthogonal standard-conforming type finalization tests damian at archaeologic dot codes
  2022-05-11  3:01 ` [Bug fortran/105542] " jvdelisle at gcc dot gnu.org
@ 2022-05-11  3:11 ` damian at archaeologic dot codes
  2022-05-11  3:17 ` jvdelisle at gcc dot gnu.org
  2022-05-11 17:41 ` everythingfunctional at protonmail dot com
  3 siblings, 0 replies; 5+ messages in thread
From: damian at archaeologic dot codes @ 2022-05-11  3:11 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105542

--- Comment #2 from Damian Rouson <damian at archaeologic dot codes> ---
Thanks for trying this, Jerry.  Brad encountered a similar issue, which I think
he resolved so I'll I'll ask him to comment here.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug fortran/105542] [F03] Orthogonal standard-conforming type finalization tests
  2022-05-10  5:14 [Bug fortran/105542] New: [F03] Orthogonal standard-conforming type finalization tests damian at archaeologic dot codes
  2022-05-11  3:01 ` [Bug fortran/105542] " jvdelisle at gcc dot gnu.org
  2022-05-11  3:11 ` damian at archaeologic dot codes
@ 2022-05-11  3:17 ` jvdelisle at gcc dot gnu.org
  2022-05-11 17:41 ` everythingfunctional at protonmail dot com
  3 siblings, 0 replies; 5+ messages in thread
From: jvdelisle at gcc dot gnu.org @ 2022-05-11  3:17 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105542

--- Comment #3 from Jerry DeLisle <jvdelisle at gcc dot gnu.org> ---
This is probably not the right place, but all gfortranners, try fpm if you have
not already done so.  It makes building and running the tests in this example
so easy.  Not to mention your own applications.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug fortran/105542] [F03] Orthogonal standard-conforming type finalization tests
  2022-05-10  5:14 [Bug fortran/105542] New: [F03] Orthogonal standard-conforming type finalization tests damian at archaeologic dot codes
                   ` (2 preceding siblings ...)
  2022-05-11  3:17 ` jvdelisle at gcc dot gnu.org
@ 2022-05-11 17:41 ` everythingfunctional at protonmail dot com
  3 siblings, 0 replies; 5+ messages in thread
From: everythingfunctional at protonmail dot com @ 2022-05-11 17:41 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105542

Brad Richardson <everythingfunctional at protonmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |everythingfunctional@proton
                   |                            |mail.com

--- Comment #4 from Brad Richardson <everythingfunctional at protonmail dot com> ---
Hi Jerry,

I recently added some new tests that are causing gfortran to crash, see the
runtime error you show:

At line 42 of file test/usage_test.f90
Fortran runtime error: Attempt to DEALLOCATE unallocated 'the_resource'

The output that Damian shows is from prior to adding those tests, and the
reported test failures describe the aspects of finalization that gfortran is
not performing correctly. You can check out commit f7cfe04 to see those
failures. Specifically gfortran fails to finalize:

* a non-allocatable object on the LHS of an intrinsic assignment
* an allocated allocatable LHS of an intrinsic assignment
* a function reference on the RHS of an intrinsic assignment
* a specification expression function result

Let me know if you need any more help identifying/exploring the test failures.

PS glad you had a good experience with fpm

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2022-05-11 17:41 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-10  5:14 [Bug fortran/105542] New: [F03] Orthogonal standard-conforming type finalization tests damian at archaeologic dot codes
2022-05-11  3:01 ` [Bug fortran/105542] " jvdelisle at gcc dot gnu.org
2022-05-11  3:11 ` damian at archaeologic dot codes
2022-05-11  3:17 ` jvdelisle at gcc dot gnu.org
2022-05-11 17:41 ` everythingfunctional at protonmail dot com

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).