https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105190
Bug ID: 105190
Summary: False positive from -Wanalyzer-malloc-leak with
symbolic writes to structs
Product: gcc
Version: 12.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: analyzer
Assignee: dmalcolm at gcc dot gnu.org
Reporter: dmalcolm at gcc dot gnu.org
Target Milestone: ---
Discovered whilst working on the fix for PR analyzer/102308:
#include "analyzer-decls.h"
struct st
{
void *ptr[10];
int arr[10];
};
struct st
test_conc_sym_ptr_sym_conc_arr (int i, struct st *p)
{
struct st s;
s.ptr[i] = __builtin_malloc (1024);
__analyzer_describe (0, s.ptr[i]); /* { dg-warning "HEAP_ALLOCATED_REGION" }
*/
p->arr[5] = 42;
__analyzer_describe (0, s.ptr[i]); /* { dg-warning "HEAP_ALLOCATED_REGION" }
*/
__analyzer_describe (0, p->arr[5]); /* { dg-warning "42" } */
return s;
} /* { dg-bogus "leak" "" { xfail *-*-* } } */
// TODO: ^^XFAIL
struct st
test_conc_sym_ptr_sym_sym_arr (int i, struct st *p, int j)
{
struct st s;
s.ptr[i] = __builtin_malloc (1024);
__analyzer_describe (0, s.ptr[i]); /* { dg-warning "HEAP_ALLOCATED_REGION" }
*/
p->arr[j] = 42;
__analyzer_describe (0, s.ptr[i]); /* { dg-warning "HEAP_ALLOCATED_REGION" }
*/
__analyzer_describe (0, p->arr[j]); /* { dg-warning "42" } */
return s;
} /* { dg-bogus "leak" "" { xfail *-*-* } } */
// TODO: ^^XFAIL