[PATCH v1 09/12] malloctest/init.c: Added pragmas to address gcc 12 warnings

Joel Sherrill joel at rtems.org
Wed Aug 17 02:16:49 UTC 2022


On Tue, Aug 16, 2022, 6:07 PM Chris Johns <chrisj at rtems.org> wrote:

> On 17/8/2022 6:11 am, Ryan Long wrote:
> > Fixed four warnings disabled were for "-Wuse-after-free" and one for a
> > "-Wfree-nonheap-object."
>
> Is this a gcc warning bug? If p1 was used to access the memory the warning
> is
> right but we are only referencing the address and not the data. It is no
> different to:
>
>   void* p = 0x111111111;
>   printf("P is %p\n", p);
>
> This is fine and has to be or we could never access any hardware.
>

That example is different I think. Semantically after a call to free, the
address is no longer valid for any use. Ensuring you don't call another
member of the malloc family is a legitimate way to avoid double frees.

If we have an issue with a specific use case pattern that GCC is tripping,
then we discuss it with them. I'm sure all of these were well thought out.

Besides this code is pushing deliberate error conditions so we should not
be surprised that the compiler is detecting issues with the code.

--joel

>
> Chris
> _______________________________________________
> devel mailing list
> devel at rtems.org
> http://lists.rtems.org/mailman/listinfo/devel
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.rtems.org/pipermail/devel/attachments/20220816/07ca45af/attachment.htm>


More information about the devel mailing list