public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug analyzer/108879] New: -Wanalyzer-malloc-leak false positive stl string in try catch block
@ 2023-02-21 22:42 jg at jguk dot org
2023-02-22 18:16 ` [Bug analyzer/108879] " dmalcolm at gcc dot gnu.org
2023-02-26 22:52 ` jg at jguk dot org
0 siblings, 2 replies; 3+ messages in thread
From: jg at jguk dot org @ 2023-02-21 22:42 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108879
Bug ID: 108879
Summary: -Wanalyzer-malloc-leak false positive stl string in
try catch block
Product: gcc
Version: 13.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: analyzer
Assignee: dmalcolm at gcc dot gnu.org
Reporter: jg at jguk dot org
Target Milestone: ---
Tested just now on gcc (trunk). Source code below and the output.
https://godbolt.org/z/Ms6fezGvT
<source>: In function 'void make_string(const char*, std::string&)':
<source>:11:27: warning: leak of
'<anonymous>.std::__cxx11::basic_string<char>::_M_dataplus.std::__cxx11::basic_string<char>::_Alloc_hider::_M_p'
[CWE-401] [-Wanalyzer-malloc-leak]
11 | out_string = std::string(str);
| ^~~~~~~~~~~
'void make_string(const char*, std::string&)': events 1-2
|
| 7 | void make_string(const char * const str, std::string & out_string)
| | ^~~~~~~~~~~
| | |
| | (1) entry to 'make_string'
|......
| 11 | out_string = std::string(str);
| | ~~~~~~~~~~~
| | |
| | (2) calling
'std::__cxx11::basic_string<char>::basic_string<>' from 'make_string'
// -fanalyzer -std=c++23 -O1 -Wall -Wno-analyzer-use-of-uninitialized-value
#include <string>
#include <cstdio>
void make_string(const char * const str, std::string & out_string)
{
try
{
out_string = std::string(str);
}
catch (std::exception& ex)
{
printf("exception %s\n", ex.what());
fflush(stdout);
}
}
int main()
{
std::string str;
make_string(NULL, str);
}
^ permalink raw reply [flat|nested] 3+ messages in thread
* [Bug analyzer/108879] -Wanalyzer-malloc-leak false positive stl string in try catch block
2023-02-21 22:42 [Bug analyzer/108879] New: -Wanalyzer-malloc-leak false positive stl string in try catch block jg at jguk dot org
@ 2023-02-22 18:16 ` dmalcolm at gcc dot gnu.org
2023-02-26 22:52 ` jg at jguk dot org
1 sibling, 0 replies; 3+ messages in thread
From: dmalcolm at gcc dot gnu.org @ 2023-02-22 18:16 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108879
David Malcolm <dmalcolm at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Blocks| |97110
--- Comment #1 from David Malcolm <dmalcolm at gcc dot gnu.org> ---
Yeah, I haven't implemented exceptions yet, so even the simplest cases are
likely to fail :-/
I plan to spent a chunk of my GCC *14* cycles working on C++ support (in the
hope of "eating my own dogfood" for GCC 14), but in the meantime, I'm afraid
it's not going to be helpful to file any more bugs about -fanalyzer on C++.
I've added a caveat about that to the GCC 13 release notes:
https://gcc.gnu.org/git/?p=gcc-wwwdocs.git;a=commitdiff;h=98c77c7cd4fc3f1bb1e77e260640cbbe5fd45b46
and to the manpage/docs:
https://gcc.gnu.org/git/?p=gcc.git;a=commitdiff;h=a90316c6ceddfbb47b3c2161baf446ccb87df5ff
Referenced Bugs:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97110
[Bug 97110] [meta-bug] tracker bug for supporting C++ in -fanalyzer
^ permalink raw reply [flat|nested] 3+ messages in thread
* [Bug analyzer/108879] -Wanalyzer-malloc-leak false positive stl string in try catch block
2023-02-21 22:42 [Bug analyzer/108879] New: -Wanalyzer-malloc-leak false positive stl string in try catch block jg at jguk dot org
2023-02-22 18:16 ` [Bug analyzer/108879] " dmalcolm at gcc dot gnu.org
@ 2023-02-26 22:52 ` jg at jguk dot org
1 sibling, 0 replies; 3+ messages in thread
From: jg at jguk dot org @ 2023-02-26 22:52 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108879
--- Comment #2 from Jonny Grant <jg at jguk dot org> ---
(In reply to David Malcolm from comment #1)
> Yeah, I haven't implemented exceptions yet, so even the simplest cases are
> likely to fail :-/
>
> I plan to spent a chunk of my GCC *14* cycles working on C++ support (in the
> hope of "eating my own dogfood" for GCC 14), but in the meantime, I'm afraid
> it's not going to be helpful to file any more bugs about -fanalyzer on C++.
>
> I've added a caveat about that to the GCC 13 release notes:
> https://gcc.gnu.org/git/?p=gcc-wwwdocs.git;a=commitdiff;
> h=98c77c7cd4fc3f1bb1e77e260640cbbe5fd45b46
>
> and to the manpage/docs:
> https://gcc.gnu.org/git/?p=gcc.git;a=commitdiff;
> h=a90316c6ceddfbb47b3c2161baf446ccb87df5ff
Many thanks for you reply. Looking forward to trying out in future GCC
releases! thank you for working on such useful features.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2023-02-26 22:52 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-02-21 22:42 [Bug analyzer/108879] New: -Wanalyzer-malloc-leak false positive stl string in try catch block jg at jguk dot org
2023-02-22 18:16 ` [Bug analyzer/108879] " dmalcolm at gcc dot gnu.org
2023-02-26 22:52 ` jg at jguk dot org
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).