public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/93925] Invalid memory reference upon call of a routine taking a procedure pointer as argument
       [not found] <bug-93925-4@http.gcc.gnu.org/bugzilla/>
@ 2021-01-25 20:04 ` tkoenig at gcc dot gnu.org
  2021-01-26  5:57 ` mscfd at gmx dot net
                   ` (11 subsequent siblings)
  12 siblings, 0 replies; 13+ messages in thread
From: tkoenig at gcc dot gnu.org @ 2021-01-25 20:04 UTC (permalink / raw)
  To: gcc-bugs

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

Thomas Koenig <tkoenig at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |tkoenig at gcc dot gnu.org
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|---                         |INVALID

--- Comment #1 from Thomas Koenig <tkoenig at gcc dot gnu.org> ---
The test case violates, 15.5.2.4  Ordinary dummy variables, subsection 11
of the F2018 standard:

If the dummy argument has the TARGET attribute and the effective argument
does not have the TARGET attribute or is an array section with a vector
subscript, any pointers associated with the dummy argument
become undefined when execution of the procedure completes.

fun returns an undefined pointer, so anything can happen (including
a segfault).

nagfor catches this, by the way:

Runtime Error: 93925.f90, line 36: Reference to dangling pointer P
Target was RETURNed from procedure F

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

* [Bug fortran/93925] Invalid memory reference upon call of a routine taking a procedure pointer as argument
       [not found] <bug-93925-4@http.gcc.gnu.org/bugzilla/>
  2021-01-25 20:04 ` [Bug fortran/93925] Invalid memory reference upon call of a routine taking a procedure pointer as argument tkoenig at gcc dot gnu.org
@ 2021-01-26  5:57 ` mscfd at gmx dot net
  2021-01-26  5:58 ` mscfd at gmx dot net
                   ` (10 subsequent siblings)
  12 siblings, 0 replies; 13+ messages in thread
From: mscfd at gmx dot net @ 2021-01-26  5:57 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from martin <mscfd at gmx dot net> ---
Created attachment 50048
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=50048&action=edit
classStar_map2 with pointer attribute for variable x

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

* [Bug fortran/93925] Invalid memory reference upon call of a routine taking a procedure pointer as argument
       [not found] <bug-93925-4@http.gcc.gnu.org/bugzilla/>
  2021-01-25 20:04 ` [Bug fortran/93925] Invalid memory reference upon call of a routine taking a procedure pointer as argument tkoenig at gcc dot gnu.org
  2021-01-26  5:57 ` mscfd at gmx dot net
@ 2021-01-26  5:58 ` mscfd at gmx dot net
  2021-01-26  5:59 ` mscfd at gmx dot net
                   ` (9 subsequent siblings)
  12 siblings, 0 replies; 13+ messages in thread
From: mscfd at gmx dot net @ 2021-01-26  5:58 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from martin <mscfd at gmx dot net> ---
Created attachment 50049
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=50049&action=edit
classStar_map3 with class(*), pointer for variable x

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

* [Bug fortran/93925] Invalid memory reference upon call of a routine taking a procedure pointer as argument
       [not found] <bug-93925-4@http.gcc.gnu.org/bugzilla/>
                   ` (2 preceding siblings ...)
  2021-01-26  5:58 ` mscfd at gmx dot net
@ 2021-01-26  5:59 ` mscfd at gmx dot net
  2021-01-26  5:59 ` mscfd at gmx dot net
                   ` (8 subsequent siblings)
  12 siblings, 0 replies; 13+ messages in thread
From: mscfd at gmx dot net @ 2021-01-26  5:59 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 from martin <mscfd at gmx dot net> ---
Created attachment 50050
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=50050&action=edit
classStar_map4 without target nor pointer attributes for variable x

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

* [Bug fortran/93925] Invalid memory reference upon call of a routine taking a procedure pointer as argument
       [not found] <bug-93925-4@http.gcc.gnu.org/bugzilla/>
                   ` (3 preceding siblings ...)
  2021-01-26  5:59 ` mscfd at gmx dot net
@ 2021-01-26  5:59 ` mscfd at gmx dot net
  2021-01-26  6:48 ` tkoenig at gcc dot gnu.org
                   ` (7 subsequent siblings)
  12 siblings, 0 replies; 13+ messages in thread
From: mscfd at gmx dot net @ 2021-01-26  5:59 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #5 from martin <mscfd at gmx dot net> ---
Sorry for this invalid test case, obviously I did reduce too much. The three
attached variations should hopefully all be conforming to the standard and
still produce the same error. Please reopen if the testcases are ok now.

The attached classStar_map2 is a slight variation on the original code, and
just uses an "integer, pointer" variable for x (as is roughly the context where
I originally encountered the bug).

classStar_map3 has no target attribute but uses "class(*), pointer" for
variable as well as argument x.

classStar_map4 is a bit further reduced. It has no target nor pointer attribute
for x, but does not use the value of x, just returns y=>null() and y=987456.

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

* [Bug fortran/93925] Invalid memory reference upon call of a routine taking a procedure pointer as argument
       [not found] <bug-93925-4@http.gcc.gnu.org/bugzilla/>
                   ` (4 preceding siblings ...)
  2021-01-26  5:59 ` mscfd at gmx dot net
@ 2021-01-26  6:48 ` tkoenig at gcc dot gnu.org
  2021-01-27 11:16 ` pault at gcc dot gnu.org
                   ` (6 subsequent siblings)
  12 siblings, 0 replies; 13+ messages in thread
From: tkoenig at gcc dot gnu.org @ 2021-01-26  6:48 UTC (permalink / raw)
  To: gcc-bugs

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

Thomas Koenig <tkoenig at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
     Ever confirmed|0                           |1
         Resolution|INVALID                     |---
             Blocks|                            |20585
   Last reconfirmed|                            |2021-01-26
             Status|RESOLVED                    |NEW

--- Comment #6 from Thomas Koenig <tkoenig at gcc dot gnu.org> ---
OK, these test cases look valid.

Reopening.


Referenced Bugs:

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=20585
[Bug 20585] [meta-bug] Fortran 2003 support

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

* [Bug fortran/93925] Invalid memory reference upon call of a routine taking a procedure pointer as argument
       [not found] <bug-93925-4@http.gcc.gnu.org/bugzilla/>
                   ` (5 preceding siblings ...)
  2021-01-26  6:48 ` tkoenig at gcc dot gnu.org
@ 2021-01-27 11:16 ` pault at gcc dot gnu.org
  2021-01-27 11:34 ` cvs-commit at gcc dot gnu.org
                   ` (5 subsequent siblings)
  12 siblings, 0 replies; 13+ messages in thread
From: pault at gcc dot gnu.org @ 2021-01-27 11:16 UTC (permalink / raw)
  To: gcc-bugs

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

Paul Thomas <pault at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |pault at gcc dot gnu.org
           Assignee|unassigned at gcc dot gnu.org      |pault at gcc dot gnu.org

--- Comment #7 from Paul Thomas <pault at gcc dot gnu.org> ---
Ah, go on! It's on my tree - I'll commit as obvious.

Paul

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

* [Bug fortran/93925] Invalid memory reference upon call of a routine taking a procedure pointer as argument
       [not found] <bug-93925-4@http.gcc.gnu.org/bugzilla/>
                   ` (6 preceding siblings ...)
  2021-01-27 11:16 ` pault at gcc dot gnu.org
@ 2021-01-27 11:34 ` cvs-commit at gcc dot gnu.org
  2021-05-04 12:32 ` rguenth at gcc dot gnu.org
                   ` (4 subsequent siblings)
  12 siblings, 0 replies; 13+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2021-01-27 11:34 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #8 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Paul Thomas <pault@gcc.gnu.org>:

https://gcc.gnu.org/g:4225af228b5d52e8d7593dea49584c91b4bc2e1f

commit r11-6928-g4225af228b5d52e8d7593dea49584c91b4bc2e1f
Author: Paul Thomas <pault@gcc.gnu.org>
Date:   Wed Jan 27 11:34:02 2021 +0000

    Fortran: Fix ICE due to elemental procedure pointers [PR93924/5].

    2021-01-27  Paul Thomas  <pault@gcc.gnu.org>

    gcc/fortran
            PR fortran/93924
            PR fortran/93925
            * trans-expr.c (gfc_conv_procedure_call): Suppress the call to
            gfc_conv_intrinsic_to_class for unlimited polymorphic procedure
            pointers.
            (gfc_trans_assignment_1): Similarly suppress class assignment
            for class valued procedure pointers.

    gcc/testsuite/
            PR fortran/93924
            PR fortran/93925
            * gfortran.dg/proc_ptr_52.f90 : New test.

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

* [Bug fortran/93925] Invalid memory reference upon call of a routine taking a procedure pointer as argument
       [not found] <bug-93925-4@http.gcc.gnu.org/bugzilla/>
                   ` (7 preceding siblings ...)
  2021-01-27 11:34 ` cvs-commit at gcc dot gnu.org
@ 2021-05-04 12:32 ` rguenth at gcc dot gnu.org
  2021-08-28 19:57 ` cvs-commit at gcc dot gnu.org
                   ` (3 subsequent siblings)
  12 siblings, 0 replies; 13+ messages in thread
From: rguenth at gcc dot gnu.org @ 2021-05-04 12:32 UTC (permalink / raw)
  To: gcc-bugs

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

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |ASSIGNED

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

* [Bug fortran/93925] Invalid memory reference upon call of a routine taking a procedure pointer as argument
       [not found] <bug-93925-4@http.gcc.gnu.org/bugzilla/>
                   ` (8 preceding siblings ...)
  2021-05-04 12:32 ` rguenth at gcc dot gnu.org
@ 2021-08-28 19:57 ` cvs-commit at gcc dot gnu.org
  2021-08-28 19:58 ` anlauf at gcc dot gnu.org
                   ` (2 subsequent siblings)
  12 siblings, 0 replies; 13+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2021-08-28 19:57 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #9 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-10 branch has been updated by Harald Anlauf
<anlauf@gcc.gnu.org>:

https://gcc.gnu.org/g:bf22e268b5c2a03216503254cfcb828016a7d998

commit r10-10077-gbf22e268b5c2a03216503254cfcb828016a7d998
Author: Paul Thomas <pault@gcc.gnu.org>
Date:   Wed Jan 27 11:34:02 2021 +0000

    Fortran: Fix ICE due to elemental procedure pointers [PR93924/5].

    2021-01-27  Paul Thomas  <pault@gcc.gnu.org>

    gcc/fortran
            PR fortran/93924
            PR fortran/93925
            * trans-expr.c (gfc_conv_procedure_call): Suppress the call to
            gfc_conv_intrinsic_to_class for unlimited polymorphic procedure
            pointers.
            (gfc_trans_assignment_1): Similarly suppress class assignment
            for class valued procedure pointers.

    gcc/testsuite/
            PR fortran/93924
            PR fortran/93925
            * gfortran.dg/proc_ptr_52.f90 : New test.

    (cherry picked from commit 4225af228b5d52e8d7593dea49584c91b4bc2e1f)

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

* [Bug fortran/93925] Invalid memory reference upon call of a routine taking a procedure pointer as argument
       [not found] <bug-93925-4@http.gcc.gnu.org/bugzilla/>
                   ` (9 preceding siblings ...)
  2021-08-28 19:57 ` cvs-commit at gcc dot gnu.org
@ 2021-08-28 19:58 ` anlauf at gcc dot gnu.org
  2021-09-06 18:43 ` cvs-commit at gcc dot gnu.org
  2021-09-06 18:48 ` anlauf at gcc dot gnu.org
  12 siblings, 0 replies; 13+ messages in thread
From: anlauf at gcc dot gnu.org @ 2021-08-28 19:58 UTC (permalink / raw)
  To: gcc-bugs

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

anlauf at gcc dot gnu.org changed:

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

--- Comment #10 from anlauf at gcc dot gnu.org ---
Cherry-picked to 10-branch for Paul after verifying that this fixes the issue.

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

* [Bug fortran/93925] Invalid memory reference upon call of a routine taking a procedure pointer as argument
       [not found] <bug-93925-4@http.gcc.gnu.org/bugzilla/>
                   ` (10 preceding siblings ...)
  2021-08-28 19:58 ` anlauf at gcc dot gnu.org
@ 2021-09-06 18:43 ` cvs-commit at gcc dot gnu.org
  2021-09-06 18:48 ` anlauf at gcc dot gnu.org
  12 siblings, 0 replies; 13+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2021-09-06 18:43 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #11 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-9 branch has been updated by Harald Anlauf
<anlauf@gcc.gnu.org>:

https://gcc.gnu.org/g:49cefbec30499da06f90912090bcc5eabdfefa32

commit r9-9710-g49cefbec30499da06f90912090bcc5eabdfefa32
Author: Paul Thomas <pault@gcc.gnu.org>
Date:   Wed Jan 27 11:34:02 2021 +0000

    Fortran: Fix ICE due to elemental procedure pointers [PR93924/5].

    2021-01-27  Paul Thomas  <pault@gcc.gnu.org>

    gcc/fortran
            PR fortran/93924
            PR fortran/93925
            * trans-expr.c (gfc_conv_procedure_call): Suppress the call to
            gfc_conv_intrinsic_to_class for unlimited polymorphic procedure
            pointers.
            (gfc_trans_assignment_1): Similarly suppress class assignment
            for class valued procedure pointers.

    gcc/testsuite/
            PR fortran/93924
            PR fortran/93925
            * gfortran.dg/proc_ptr_52.f90 : New test.

    (cherry picked from commit 4225af228b5d52e8d7593dea49584c91b4bc2e1f)

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

* [Bug fortran/93925] Invalid memory reference upon call of a routine taking a procedure pointer as argument
       [not found] <bug-93925-4@http.gcc.gnu.org/bugzilla/>
                   ` (11 preceding siblings ...)
  2021-09-06 18:43 ` cvs-commit at gcc dot gnu.org
@ 2021-09-06 18:48 ` anlauf at gcc dot gnu.org
  12 siblings, 0 replies; 13+ messages in thread
From: anlauf at gcc dot gnu.org @ 2021-09-06 18:48 UTC (permalink / raw)
  To: gcc-bugs

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

anlauf at gcc dot gnu.org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|---                         |FIXED

--- Comment #12 from anlauf at gcc dot gnu.org ---
Should be fixed on all open branches.  Closing.

Thanks for the report!

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

end of thread, other threads:[~2021-09-06 18:48 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <bug-93925-4@http.gcc.gnu.org/bugzilla/>
2021-01-25 20:04 ` [Bug fortran/93925] Invalid memory reference upon call of a routine taking a procedure pointer as argument tkoenig at gcc dot gnu.org
2021-01-26  5:57 ` mscfd at gmx dot net
2021-01-26  5:58 ` mscfd at gmx dot net
2021-01-26  5:59 ` mscfd at gmx dot net
2021-01-26  5:59 ` mscfd at gmx dot net
2021-01-26  6:48 ` tkoenig at gcc dot gnu.org
2021-01-27 11:16 ` pault at gcc dot gnu.org
2021-01-27 11:34 ` cvs-commit at gcc dot gnu.org
2021-05-04 12:32 ` rguenth at gcc dot gnu.org
2021-08-28 19:57 ` cvs-commit at gcc dot gnu.org
2021-08-28 19:58 ` anlauf at gcc dot gnu.org
2021-09-06 18:43 ` cvs-commit at gcc dot gnu.org
2021-09-06 18:48 ` anlauf at gcc dot gnu.org

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).