Unable to get rid of -Wfree-nonheap-object warnings
23:29 19 Apr 2023

I am trying to migrate code from older gcc (7.5.0) to newer 11.3.0. All working, tested code, but I am not able to get rid of some warnings (I use -Werror) like:

warning: ‘free’ called on pointer ‘ptr357’ with nonzero offset 24 [`-Wfree-nonheap-object`]

Even with -Wno-free-nonheap-object ! I searched some articles and also tried to disable Link-time-optimization with -fno-lto, still I see a lot of the above, and bunch of the following

warning: type of ‘do_enable_p’ does not match original declaration [-Wlto-type-mismatch]

(even with -Wno-lto-type-mismatch)

Am I missing some other flags to gcc or this has to be gotten rid of, with the #pragmas in code ?

P.S. I am on Ubuntu-22.04

c gcc ubuntu-22.04