public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* -fanalyzer: Questions on C vs CPP + use of GCC attr's like malloc()/access()
@ 2022-11-24  1:49 Gavin Ray
  2022-11-25 17:33 ` David Malcolm
  0 siblings, 1 reply; 7+ messages in thread
From: Gavin Ray @ 2022-11-24  1:49 UTC (permalink / raw)
  To: gcc

[-- Attachment #1: Type: text/plain, Size: 1005 bytes --]

Hey all, just a few questions about the fantastic GCC Static Analyzer:

- It's stated that support for C++ vs C is very limited. Does this apply if
  you're writing C++ that is very similar-looking to C and uses few of C++'s
  advanced features?

- I noticed that in C++, the "gnu::malloc" attributes don't seem to report
  "warning: leak of 'xxx_alloc()' [CWE-401] [-Wanalyzer-malloc-leak]", is
this
  normal?

- Is it worthwhile to spend time annotating your method signatures with
  attributes like "malloc" and "access"? Do these aid the -fanalyzer passes?

For instance:

[[gnu::malloc]] [[gnu::malloc(HeapPage_free, 1)]] [[gnu::returns_nonnull]]
struct HeapPage* HeapPage_alloc();

[[gnu::access(read_write, 1, 3)]]
struct RecordID
HeapPage_insert_record(struct HeapPage* page, const char* record,
                       uint32_t record_length);

That's quite a significant bit of annotation-noise tacked on to the
function, so
I wanted to be sure it's worth the investment!

Thank you =)
Gavin Ray

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2022-11-26 18:51 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-11-24  1:49 -fanalyzer: Questions on C vs CPP + use of GCC attr's like malloc()/access() Gavin Ray
2022-11-25 17:33 ` David Malcolm
2022-11-25 18:55   ` Gavin Ray
2022-11-26 14:09     ` Jonathan Wakely
2022-11-26 15:48       ` Gavin Ray
2022-11-26 17:47         ` Jonathan Wakely
2022-11-26 18:51           ` David Malcolm

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).