[Bug middle-end/54202] Overeager warning about freeing non-heap objects
mserdarsanli at gmail dot com
gcc-bugzilla@gcc.gnu.org
Wed Jun 16 13:19:06 GMT 2021
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=54202
Serdar Sanli <mserdarsanli at gmail dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |mserdarsanli at gmail dot com
--- Comment #9 from Serdar Sanli <mserdarsanli at gmail dot com> ---
A simpler example not involving any globals, causing Wfree-nonheap-object
warning since GCC11
https://godbolt.org/z/MYn1zrjE4
===
struct Foo {
void allocate(int n);
void deallocate();
int *_data;
};
void Foo::allocate(int n) {
_data = new int[n] - 1;
}
void Foo::deallocate() {
delete[] (_data+1);
}
More information about the Gcc-bugs
mailing list