On Fri, Nov 01, 2024 at 11:39:13AM +0100, Jan Hubicka wrote:
> The testcase does:
> /* { dg-additional-options "-O3 -fsanitize=undefined" } */
> 
> void memory_exhausted();
> void memcheck(void *ptr) {
>   if (ptr) /* { dg-warning "leak" } */
>     memory_exhausted();
> }
> 
> int emalloc(int size) { memcheck(__builtin_malloc(size)); } /* { dg-message 
> "allocated here" } */
> int main() { int max_envvar_len = emalloc(max_envvar_len + 1); } /* { 
> dg-message "use of uninitialized value 'max_envvar_len'" } */

The PR was an ICE fix, so I think it is ok to say add -fno-allocation-dce
or somehow arrange in the source for the call not to be optimized away,
as long as it still ICEs in r12-3094 and succeeds with r12-3095 after
that change.

Generally regarding warnings, if the compiler optimizes away the allocation
altogether, there will be no leak from it, so I think the optimization is
fine.

        Jakub

Reply via email to