public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/100132] New: Optimization breaks pointer association
@ 2021-04-17 23:38 jrfsousa at gmail dot com
2021-04-18 0:20 ` [Bug fortran/100132] " jrfsousa at gmail dot com
` (9 more replies)
0 siblings, 10 replies; 11+ messages in thread
From: jrfsousa at gmail dot com @ 2021-04-17 23:38 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100132
Bug ID: 100132
Summary: Optimization breaks pointer association
Product: gcc
Version: 11.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: fortran
Assignee: unassigned at gcc dot gnu.org
Reporter: jrfsousa at gmail dot com
Target Milestone: ---
Created attachment 50622
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=50622&action=edit
Fortran code showing problem
Hi All!
Pointer association is lost when compiling with -O1 or -O2, curiously not with
-O3 unless -fcheck=recursion is used
Seen on:
GNU Fortran (GCC) 11.0.1 20210417 (experimental)
GNU Fortran (GCC) 10.3.1 20210417
GNU Fortran (GCC) 9.3.1 20210417
Thank you very much.
Best regards,
José Rui
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug fortran/100132] Optimization breaks pointer association
2021-04-17 23:38 [Bug fortran/100132] New: Optimization breaks pointer association jrfsousa at gmail dot com
@ 2021-04-18 0:20 ` jrfsousa at gmail dot com
2021-04-18 9:43 ` dominiq at lps dot ens.fr
` (8 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: jrfsousa at gmail dot com @ 2021-04-18 0:20 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100132
--- Comment #1 from José Rui Faustino de Sousa <jrfsousa at gmail dot com> ---
Patch posted
https://gcc.gnu.org/pipermail/fortran/2021-April/055946.html
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug fortran/100132] Optimization breaks pointer association
2021-04-17 23:38 [Bug fortran/100132] New: Optimization breaks pointer association jrfsousa at gmail dot com
2021-04-18 0:20 ` [Bug fortran/100132] " jrfsousa at gmail dot com
@ 2021-04-18 9:43 ` dominiq at lps dot ens.fr
2022-09-18 19:11 ` anlauf at gcc dot gnu.org
` (7 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: dominiq at lps dot ens.fr @ 2021-04-18 9:43 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100132
Dominique d'Humieres <dominiq at lps dot ens.fr> changed:
What |Removed |Added
----------------------------------------------------------------------------
Last reconfirmed| |2021-04-18
Ever confirmed|0 |1
Status|UNCONFIRMED |NEW
--- Comment #2 from Dominique d'Humieres <dominiq at lps dot ens.fr> ---
Confirmed since at least GCC7.
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug fortran/100132] Optimization breaks pointer association
2021-04-17 23:38 [Bug fortran/100132] New: Optimization breaks pointer association jrfsousa at gmail dot com
2021-04-18 0:20 ` [Bug fortran/100132] " jrfsousa at gmail dot com
2021-04-18 9:43 ` dominiq at lps dot ens.fr
@ 2022-09-18 19:11 ` anlauf at gcc dot gnu.org
2022-09-19 20:21 ` anlauf at gcc dot gnu.org
` (6 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: anlauf at gcc dot gnu.org @ 2022-09-18 19:11 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100132
anlauf at gcc dot gnu.org changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |anlauf at gcc dot gnu.org
--- Comment #3 from anlauf at gcc dot gnu.org ---
(In reply to José Rui Faustino de Sousa from comment #1)
> Patch posted
>
> https://gcc.gnu.org/pipermail/fortran/2021-April/055946.html
The patch is technically fine and regtests ok, but was unfortunately never
reviewed.
The basic fix can be slightly shortened to:
diff --git a/gcc/fortran/trans-types.cc b/gcc/fortran/trans-types.cc
index 0ea7c74a6f1..c062a5b29d7 100644
--- a/gcc/fortran/trans-types.cc
+++ b/gcc/fortran/trans-types.cc
@@ -3054,12 +3054,23 @@ create_fn_spec (gfc_symbol *sym, tree fntype)
for (f = gfc_sym_get_dummy_args (sym); f; f = f->next)
if (spec_len < sizeof (spec))
{
- if (!f->sym || f->sym->attr.pointer || f->sym->attr.target
+ bool is_class = false;
+ bool is_pointer = false;
+
+ if (f->sym)
+ {
+ is_class = f->sym->ts.type == BT_CLASS && CLASS_DATA (f->sym)
+ && f->sym->attr.class_ok;
+ is_pointer = is_class ? CLASS_DATA (f->sym)->attr.class_pointer
+ : f->sym->attr.pointer;
+ }
+
+ if (f->sym == NULL || is_pointer || f->sym->attr.target
|| f->sym->attr.external || f->sym->attr.cray_pointer
|| (f->sym->ts.type == BT_DERIVED
&& (f->sym->ts.u.derived->attr.proc_pointer_comp
|| f->sym->ts.u.derived->attr.pointer_comp))
- || (f->sym->ts.type == BT_CLASS
+ || (is_class
&& (CLASS_DATA (f->sym)->ts.u.derived->attr.proc_pointer_comp
|| CLASS_DATA (f->sym)->ts.u.derived->attr.pointer_comp))
|| (f->sym->ts.type == BT_INTEGER && f->sym->ts.is_c_interop))
I can take care of it for you.
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug fortran/100132] Optimization breaks pointer association
2021-04-17 23:38 [Bug fortran/100132] New: Optimization breaks pointer association jrfsousa at gmail dot com
` (2 preceding siblings ...)
2022-09-18 19:11 ` anlauf at gcc dot gnu.org
@ 2022-09-19 20:21 ` anlauf at gcc dot gnu.org
2022-09-20 18:31 ` cvs-commit at gcc dot gnu.org
` (5 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: anlauf at gcc dot gnu.org @ 2022-09-19 20:21 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100132
--- Comment #4 from anlauf at gcc dot gnu.org ---
Pinged here: https://gcc.gnu.org/pipermail/fortran/2022-September/058212.html
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug fortran/100132] Optimization breaks pointer association
2021-04-17 23:38 [Bug fortran/100132] New: Optimization breaks pointer association jrfsousa at gmail dot com
` (3 preceding siblings ...)
2022-09-19 20:21 ` anlauf at gcc dot gnu.org
@ 2022-09-20 18:31 ` cvs-commit at gcc dot gnu.org
2022-10-01 18:17 ` cvs-commit at gcc dot gnu.org
` (4 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2022-09-20 18:31 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100132
--- Comment #5 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Harald Anlauf <anlauf@gcc.gnu.org>:
https://gcc.gnu.org/g:be60aa5b608b5f09fadfeff852a46589ac311a42
commit r13-2743-gbe60aa5b608b5f09fadfeff852a46589ac311a42
Author: José Rui Faustino de Sousa <jrfsousa@gmail.com>
Date: Mon Sep 19 22:00:45 2022 +0200
Fortran: Fix function attributes [PR100132]
gcc/fortran/ChangeLog:
PR fortran/100132
* trans-types.cc (create_fn_spec): Fix function attributes when
passing polymorphic pointers.
gcc/testsuite/ChangeLog:
PR fortran/100132
* gfortran.dg/PR100132.f90: New test.
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug fortran/100132] Optimization breaks pointer association
2021-04-17 23:38 [Bug fortran/100132] New: Optimization breaks pointer association jrfsousa at gmail dot com
` (4 preceding siblings ...)
2022-09-20 18:31 ` cvs-commit at gcc dot gnu.org
@ 2022-10-01 18:17 ` cvs-commit at gcc dot gnu.org
2022-10-01 18:40 ` cvs-commit at gcc dot gnu.org
` (3 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2022-10-01 18:17 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100132
--- Comment #6 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-12 branch has been updated by Harald Anlauf
<anlauf@gcc.gnu.org>:
https://gcc.gnu.org/g:9de83c0939dabdbefcb88dfef3ad7caf932951ec
commit r12-8802-g9de83c0939dabdbefcb88dfef3ad7caf932951ec
Author: José Rui Faustino de Sousa <jrfsousa@gmail.com>
Date: Mon Sep 19 22:00:45 2022 +0200
Fortran: Fix function attributes [PR100132]
gcc/fortran/ChangeLog:
PR fortran/100132
* trans-types.cc (create_fn_spec): Fix function attributes when
passing polymorphic pointers.
gcc/testsuite/ChangeLog:
PR fortran/100132
* gfortran.dg/PR100132.f90: New test.
(cherry picked from commit be60aa5b608b5f09fadfeff852a46589ac311a42)
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug fortran/100132] Optimization breaks pointer association
2021-04-17 23:38 [Bug fortran/100132] New: Optimization breaks pointer association jrfsousa at gmail dot com
` (5 preceding siblings ...)
2022-10-01 18:17 ` cvs-commit at gcc dot gnu.org
@ 2022-10-01 18:40 ` cvs-commit at gcc dot gnu.org
2022-10-01 18:55 ` cvs-commit at gcc dot gnu.org
` (2 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2022-10-01 18:40 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100132
--- Comment #7 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-11 branch has been updated by Harald Anlauf
<anlauf@gcc.gnu.org>:
https://gcc.gnu.org/g:cd13cc012e0bca927f97f618ab54c8d365883bbc
commit r11-10286-gcd13cc012e0bca927f97f618ab54c8d365883bbc
Author: José Rui Faustino de Sousa <jrfsousa@gmail.com>
Date: Mon Sep 19 22:00:45 2022 +0200
Fortran: Fix function attributes [PR100132]
gcc/fortran/ChangeLog:
PR fortran/100132
* trans-types.c (create_fn_spec): Fix function attributes when
passing polymorphic pointers.
gcc/testsuite/ChangeLog:
PR fortran/100132
* gfortran.dg/PR100132.f90: New test.
(cherry picked from commit be60aa5b608b5f09fadfeff852a46589ac311a42)
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug fortran/100132] Optimization breaks pointer association
2021-04-17 23:38 [Bug fortran/100132] New: Optimization breaks pointer association jrfsousa at gmail dot com
` (6 preceding siblings ...)
2022-10-01 18:40 ` cvs-commit at gcc dot gnu.org
@ 2022-10-01 18:55 ` cvs-commit at gcc dot gnu.org
2022-10-01 18:56 ` anlauf at gcc dot gnu.org
2022-10-17 20:36 ` anlauf at gcc dot gnu.org
9 siblings, 0 replies; 11+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2022-10-01 18:55 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100132
--- Comment #8 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:8c583871e70f5530907d22a21b0f1d1e7b90e224
commit r10-11015-g8c583871e70f5530907d22a21b0f1d1e7b90e224
Author: José Rui Faustino de Sousa <jrfsousa@gmail.com>
Date: Mon Sep 19 22:00:45 2022 +0200
Fortran: Fix function attributes [PR100132]
gcc/fortran/ChangeLog:
PR fortran/100132
* trans-types.c (create_fn_spec): Fix function attributes when
passing polymorphic pointers.
gcc/testsuite/ChangeLog:
PR fortran/100132
* gfortran.dg/PR100132.f90: New test.
(cherry picked from commit be60aa5b608b5f09fadfeff852a46589ac311a42)
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug fortran/100132] Optimization breaks pointer association
2021-04-17 23:38 [Bug fortran/100132] New: Optimization breaks pointer association jrfsousa at gmail dot com
` (7 preceding siblings ...)
2022-10-01 18:55 ` cvs-commit at gcc dot gnu.org
@ 2022-10-01 18:56 ` anlauf at gcc dot gnu.org
2022-10-17 20:36 ` anlauf at gcc dot gnu.org
9 siblings, 0 replies; 11+ messages in thread
From: anlauf at gcc dot gnu.org @ 2022-10-01 18:56 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100132
anlauf at gcc dot gnu.org changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
Target Milestone|--- |10.5
Resolution|--- |FIXED
--- Comment #9 from anlauf at gcc dot gnu.org ---
Fixed on all open branches. Closing.
Thanks for the patch!
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug fortran/100132] Optimization breaks pointer association
2021-04-17 23:38 [Bug fortran/100132] New: Optimization breaks pointer association jrfsousa at gmail dot com
` (8 preceding siblings ...)
2022-10-01 18:56 ` anlauf at gcc dot gnu.org
@ 2022-10-17 20:36 ` anlauf at gcc dot gnu.org
9 siblings, 0 replies; 11+ messages in thread
From: anlauf at gcc dot gnu.org @ 2022-10-17 20:36 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100132
anlauf at gcc dot gnu.org changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |damian at archaeologic dot codes
--- Comment #10 from anlauf at gcc dot gnu.org ---
*** Bug 87659 has been marked as a duplicate of this bug. ***
^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2022-10-17 20:36 UTC | newest]
Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-17 23:38 [Bug fortran/100132] New: Optimization breaks pointer association jrfsousa at gmail dot com
2021-04-18 0:20 ` [Bug fortran/100132] " jrfsousa at gmail dot com
2021-04-18 9:43 ` dominiq at lps dot ens.fr
2022-09-18 19:11 ` anlauf at gcc dot gnu.org
2022-09-19 20:21 ` anlauf at gcc dot gnu.org
2022-09-20 18:31 ` cvs-commit at gcc dot gnu.org
2022-10-01 18:17 ` cvs-commit at gcc dot gnu.org
2022-10-01 18:40 ` cvs-commit at gcc dot gnu.org
2022-10-01 18:55 ` cvs-commit at gcc dot gnu.org
2022-10-01 18:56 ` anlauf at gcc dot gnu.org
2022-10-17 20:36 ` 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).