This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug fortran/54301] New: Add optional warning if pointer assigning a local variable to a nonlocal pointer
- From: "burnus at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Fri, 17 Aug 2012 16:23:07 +0000
- Subject: [Bug fortran/54301] New: Add optional warning if pointer assigning a local variable to a nonlocal pointer
- Auto-submitted: auto-generated
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54301
Bug #: 54301
Summary: Add optional warning if pointer assigning a local
variable to a nonlocal pointer
Classification: Unclassified
Product: gcc
Version: 4.8.0
Status: UNCONFIRMED
Keywords: diagnostic
Severity: normal
Priority: P3
Component: fortran
AssignedTo: unassigned@gcc.gnu.org
ReportedBy: burnus@gcc.gnu.org
CC: tkoenig@gcc.gnu.org
Suggested by ISO/IEC Project 22.24772 "Guidance for Avoiding Vulnerabilities
through Language Selection and Use" (see links at
http://gcc.gnu.org/wiki/GFortranStandards)
From the Fortran appendix (draft at
ftp://ftp.nag.co.uk/sc22wg5/N1901-N1950/N1929.pdf)
At the end there is the suggestion:
"Fortran.58.1 Implications for Standardization"
"Future standardization eorts should consider:"
...
"* Requiring that processors have the ability to detect and report the
occurrence within a submitted program unit of pointer assignment of
a pointer whose lifetime is known to be longer than the lifetime of the
target."
I think can be diagnosed with some -W... warning in the following case: The LHS
of the pointer assignment is
a) A function result variable
b) A dummy argument
c) A host- or use-associated variable
d) A common-block variable
and the RHS is a local variable (local to the procedure or local to a BLOCK) -
but, crucially, RHS variable is not a pointer.
[At least the case (a) I have already seen in some bugreport.]