https://gcc.gnu.org/bugzilla/show_bug.cgi?id=118300
Eric Gallager <egallager at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|False malloc leak warning   |[12/13/14/15 Regression]
                   |from static analyzer        |False malloc leak warning
                   |                            |from static analyzer
           Keywords|                            |needs-bisection
                 CC|                            |egallager at gcc dot gnu.org

--- Comment #1 from Eric Gallager <egallager at gcc dot gnu.org> ---
(In reply to Fedor Chelnokov from comment #0)
> This program
> ```
> #include <stdlib.h>
> 
> int main() {
>     int*** new = malloc(sizeof(int**));
>     *new = malloc(sizeof(int*));
>     **new = malloc(sizeof(int));
> 
>     free(**new);
>     free(*new);
>     free(new);
> }
> ```
> if complied in recent GCC with `-fanalyzer -fsanitize=address,undefined`
> command-line options produce erroneous warning:

Could you be a bit more specific about which versions you mean by "recent GCC"?

> > warning: leak of 'malloc(4)' [CWE-401] [-Wanalyzer-malloc-leak]
> >    8 |     free(**new);
> >      |           ^~~~
>
> GCC 11 does not have this issue yet. Online demo:
> https://gcc.godbolt.org/z/e99naov8Y
> 
> Related discussion: https://stackoverflow.com/q/79329275/7325599

...ah, I see, "recent" means 12+... Still, it would be useful to bisect to find
the exact commit where this changed...

Reply via email to