[Bug c/71924] missing -Wreturn-local-addr returning alloca result
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=71924 Martin Sebor changed: What|Removed |Added Status|ASSIGNED|RESOLVED Resolution|--- |FIXED Target Milestone|--- |10.0 --- Comment #7 from Martin Sebor --- Patch committed in r273261.
[Bug c/71924] missing -Wreturn-local-addr returning alloca result
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=71924 --- Comment #6 from Martin Sebor --- Author: msebor Date: Tue Jul 9 04:15:42 2019 New Revision: 273261 URL: https://gcc.gnu.org/viewcvs?rev=273261=gcc=rev Log: PR middle-end/71924 - missing -Wreturn-local-addr returning alloca result PR middle-end/90549 - missing -Wreturn-local-addr maybe returning an address of a local array plus offset gcc/ChangeLog: PR middle-end/71924 PR middle-end/90549 * gimple-ssa-isolate-paths.c (isolate_path): Add attribute. Update comment. (args_loc_t): New type. (args_loc_t, locmap_t): same. (diag_returned_locals): New function. (is_addr_local): Same. (handle_return_addr_local_phi_arg, warn_return_addr_local): Same. (find_implicit_erroneous_behavior): Call warn_return_addr_local_phi_arg. (find_explicit_erroneous_behavior): Call warn_return_addr_local. gcc/testsuite/ChangeLog: PR middle-end/71924 PR middle-end/90549 * gcc.c-torture/execute/return-addr.c: New test. * gcc.dg/Wreturn-local-addr-2.c: New test. * gcc.dg/Wreturn-local-addr-4.c: New test. * gcc.dg/Wreturn-local-addr-5.c: New test. * gcc.dg/Wreturn-local-addr-6.c: New test. * gcc.dg/Wreturn-local-addr-7.c: New test. * gcc.dg/Wreturn-local-addr-8.c: New test. * gcc.dg/Wreturn-local-addr-9.c: New test. * gcc.dg/Wreturn-local-addr-10.c: New test. * gcc.dg/Walloca-4.c: Handle expected warnings. * gcc.dg/pr41551.c: Same. * gcc.dg/pr59523.c: Same. * gcc.dg/tree-ssa/pr88775-2.c: Same. * gcc.dg/tree-ssa/alias-37.c: Same. * gcc.dg/winline-7.c: Same. Added: trunk/gcc/testsuite/gcc.c-torture/execute/return-addr.c trunk/gcc/testsuite/gcc.dg/Wreturn-local-addr-10.c trunk/gcc/testsuite/gcc.dg/Wreturn-local-addr-2.c trunk/gcc/testsuite/gcc.dg/Wreturn-local-addr-3.c trunk/gcc/testsuite/gcc.dg/Wreturn-local-addr-4.c trunk/gcc/testsuite/gcc.dg/Wreturn-local-addr-5.c trunk/gcc/testsuite/gcc.dg/Wreturn-local-addr-6.c trunk/gcc/testsuite/gcc.dg/Wreturn-local-addr-7.c trunk/gcc/testsuite/gcc.dg/Wreturn-local-addr-8.c trunk/gcc/testsuite/gcc.dg/Wreturn-local-addr-9.c Modified: trunk/gcc/ChangeLog trunk/gcc/gimple-ssa-isolate-paths.c trunk/gcc/testsuite/ChangeLog trunk/gcc/testsuite/gcc.dg/Walloca-4.c trunk/gcc/testsuite/gcc.dg/pr41551.c trunk/gcc/testsuite/gcc.dg/pr59523.c trunk/gcc/testsuite/gcc.dg/tree-ssa/alias-37.c trunk/gcc/testsuite/gcc.dg/tree-ssa/pr88775-2.c trunk/gcc/testsuite/gcc.dg/winline-7.c trunk/libgcc/generic-morestack.c
[Bug c/71924] missing -Wreturn-local-addr returning alloca result
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=71924 Martin Sebor changed: What|Removed |Added Keywords||patch --- Comment #5 from Martin Sebor --- Patch: https://gcc.gnu.org/ml/gcc-patches/2019-05/msg01525.html
[Bug c/71924] missing -Wreturn-local-addr returning alloca result
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=71924 Martin Sebor changed: What|Removed |Added Status|NEW |ASSIGNED Assignee|unassigned at gcc dot gnu.org |msebor at gcc dot gnu.org --- Comment #4 from Martin Sebor --- I'm testing a patch.
[Bug c/71924] missing -Wreturn-local-addr returning alloca result
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=71924 --- Comment #3 from Martin Sebor --- On second thought, the right fix is to report the problem consistently for all kinds of storage, including auto variables, alloca-ted storage, and compound literals.
[Bug c/71924] missing -Wreturn-local-addr returning alloca result
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=71924 Richard Biener changed: What|Removed |Added Status|UNCONFIRMED |NEW Last reconfirmed||2016-07-19 Ever confirmed|0 |1
[Bug c/71924] missing -Wreturn-local-addr returning alloca result
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=71924 --- Comment #2 from Martin Sebor --- Returning [the address of] a compound literal, or any indirectly referenced object (such as those in comment #1), suffers from the same limitation. Compiling the program with -O2 (but not -O1) does produce the expected warnings. Since the effect of optimization is not documented, a "fix" might be as simple as updating the manual to mention the dependency.
[Bug c/71924] missing -Wreturn-local-addr returning alloca result
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=71924 --- Comment #1 from Andrew Pinski --- I expect we also miss: void* foo1 (void) { char a [4]; char *b = a; return b; } void* foo2 (void) { char *b = (char[4]){0, 0, 0, 0}; return b; } Basically we don't do any flow analysis for this warning.
[Bug c/71924] missing -Wreturn-local-addr returning alloca result
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=71924 Andrew Pinski changed: What|Removed |Added Severity|normal |enhancement