warning: leak of ‘ptr [-Wanalyzer-malloc-leak]
Function do_something
File ../../src/gcc/testsuite/g++.dg/analyzer/exception-leak-4.C
Line 5
Column 11
5 throw 42; // { dg-warning "leak of 'ptr'" }
^~
int test(int)
int test(int): events 1-3
8 int test (int flag)
^~~~
|
(1) entry to ‘test’
9 {
10 void *ptr = __builtin_malloc (1024); // { dg-message "allocated here" }
~~~~~~~~~~~~~~~~~~~~~~~
|
(2) allocated here
11
12 do_something (flag);
~~~~~~~~~~~~~~~~~~~
|
(3) calling ‘do_something’ from ‘test’
void do_something(int)
void do_something(int): events 4-8
2 do_something (int flag)
^~~~~~~~~~~~
|
(4) entry to ‘do_something’
3 {
4 if (flag)
~~
|
(5) following ‘true’ branch (when ‘flag != 0’)... ─>─┐
───────────────────────────────────────────────────────┘
5 throw 42; // { dg-warning "leak of 'ptr'" }
~~
|
─────────>(6) ...to here
(7) throwing exception of type ‘int’ here...
(8) ⚠️ ‘ptr’ leaks here; was allocated at (2)