Created attachment 55559 [details] Source File Observed on Trunk and 13.1.1 Consider: ```c #include <stdlib.h> typedef struct S S; struct S { int* i; }; static S* s_constructor(void) { S* s = malloc(sizeof(*s)); if (s) s->i = calloc(1, sizeof(*(s->i))); return s; } static void s_destructor(S* s) { if (!s) return; free(s->i); free(s); } static void s_destructor2(S s[static 1]) { free(s->i); free(s); } int main(void) { S* s = s_constructor(); s_destructor(s); s = s_constructor(); if (s) s_destructor2(s); s = (void*) 0; return EXIT_SUCCESS; } ``` Compiling with gcc -Wall -Werror produces the error: <source>: In function 's_destructor2': <source>:23:5: error: 'free' called on unallocated object 's' [-Werror=free-nonheap-object] 23 | free(s); | ^~~~~~~ <source>:21:29: note: declared here 21 | static void s_destructor2(S s[static 1]) { | ~~^~~~~~~~~~~ cc1: all warnings being treated as errors However, there is no error when compiled with -O1 or higher optimization flag. I don't think s_destructor2(S s[static 1]) should emit an error in the first place though. The function definition should be compatible with s_destructor(S* s).
Confirmed.
I can see it on 13.2.1 20230826. The warning triggers even without any -W* args. The manpage implies that shouldn't be the case.