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: unassig...@gcc.gnu.org ReportedBy: bur...@gcc.gnu.org CC: tkoe...@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.]