Summary: | Bogus "attempt to free a non-heap object" warning | ||
---|---|---|---|
Product: | gcc | Reporter: | Rubidium <rubidium> |
Component: | middle-end | Assignee: | Not yet assigned to anyone <unassigned> |
Status: | RESOLVED FIXED | ||
Severity: | minor | CC: | gcc-bugs, meheff, zsojka |
Priority: | P3 | Keywords: | diagnostic |
Version: | 4.4.0 | ||
Target Milestone: | 4.7.0 | ||
Host: | i686-pc-linux-gnu | Target: | i686-pc-linux-gnu |
Build: | i686-pc-linux-gnu | Known to work: | |
Known to fail: | Last reconfirmed: |
Description
Rubidium
2008-12-12 22:36:34 UTC
static int non_heap = 0; <bb 2>: if (non_heap != 0) goto <bb 3>; else goto <bb 4>; <bb 3>: __builtin_free (&non_heap); Hmm, since the address of non_heap is taken, we don't optimize away the conditional. Is there a way to disable this warning? I've searched the manual and gcc -v --help for 'heap' and 'free'. Neither keyword showed any promising compiler flags. I've also looked in the code, but I cannot find a variable (like warn_parentheses) that enables/disables the warning. This case needs the compiler needs to know that TestCase::TestCase():: non_heap cannot change value. Author: meheff Date: Tue Aug 23 18:06:42 2011 New Revision: 178004 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=178004 Log: 2011-08-23 Mark Heffernan <meheff@google.com> PR middle-end/38509 * common.opt (Wfree-nonheap-object): New option. * doc/invoke.texi (Warning options): Document -Wfree-nonheap-object. * builtins.c (maybe_emit_free_warning): Add OPT_Wfree_nonheap_object to warning. (expand_builtin): Make warning conditional. Modified: trunk/gcc/ChangeLog trunk/gcc/builtins.c trunk/gcc/common.opt trunk/gcc/doc/invoke.texi With patch, warning is controllable with -Wfree-nonheap-object. |