public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "redi at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/103233] Warning from system libraries in user code: CWE-476 -Werror=analyzer-null-dereference Date: Sun, 14 Nov 2021 14:57:40 +0000 [thread overview] Message-ID: <bug-103233-4-wXc6dUoAYW@http.gcc.gnu.org/bugzilla/> (raw) In-Reply-To: <bug-103233-4@http.gcc.gnu.org/bugzilla/> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103233 Jonathan Wakely <redi at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|UNCONFIRMED |WAITING Last reconfirmed| |2021-11-14 Ever confirmed|0 |1 --- Comment #2 from Jonathan Wakely <redi at gcc dot gnu.org> --- (In reply to Alejandro Colomar from comment #0) > There are two problems here: > > One is a dereference of a NULL pointer in the standard C++ library code > (at least that's what -fanalyzer reports). The analyzer doesn't support C++ properly yet, and is completely wrong here. See below. > Another is that I'm seeing the error while compiling user code (my library): > <https://github.com/alejandro-colomar/libalx> What error? Please provide the code to reproduce the problem, not just a URL, see https://gcc.gnu.org/bugs > |/usr/include/c++/11/bits/stl_vector.h:346:25: > | 346 | return __n != 0 ? _Tr::allocate(_M_impl, __n) : > pointer(); > | | > ~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > | | | > | | (7) following 'false' branch... This cannot happen. The length is this->size() + 1 and we already checked for overflow, so it is guaranteed to be a positive integer. > |...... > | 127 | return static_cast<_Tp*>(::operator new(__n * > sizeof(_Tp))); > | | > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > | | | > | | (12) > ...to here > | | (13) this > call could return NULL This is nonsense, operator new(size_t) cannot return null.
next prev parent reply other threads:[~2021-11-14 14:57 UTC|newest] Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top 2021-11-14 14:27 [Bug c++/103233] New: " colomar.6.4.3 at gmail dot com 2021-11-14 14:30 ` [Bug c++/103233] " colomar.6.4.3 at gmail dot com 2021-11-14 14:57 ` redi at gcc dot gnu.org [this message] 2021-11-14 15:32 ` [Bug analyzer/103233] " alx.manpages at gmail dot com 2021-11-15 23:27 ` dmalcolm at gcc dot gnu.org 2021-11-15 23:42 ` colomar.6.4.3 at gmail dot com 2021-11-15 23:48 ` colomar.6.4.3 at gmail dot com 2021-11-15 23:52 ` pinskia at gcc dot gnu.org 2021-11-16 11:32 ` alx.manpages at gmail dot com 2021-12-13 15:45 ` redi at gcc dot gnu.org
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=bug-103233-4-wXc6dUoAYW@http.gcc.gnu.org/bugzilla/ \ --to=gcc-bugzilla@gcc.gnu.org \ --cc=gcc-bugs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
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).