public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "ibuclaw at gdcproject dot org" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug middle-end/96987] [11 regression] warning 'ptr' may be used uninitialized const pointer parameter Date: Wed, 16 Sep 2020 07:41:31 +0000 [thread overview] Message-ID: <bug-96987-4-2vsABZsDGR@http.gcc.gnu.org/bugzilla/> (raw) In-Reply-To: <bug-96987-4@http.gcc.gnu.org/bugzilla/> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96987 --- Comment #4 from Iain Buclaw <ibuclaw at gdcproject dot org> --- And what about void pointers? How is it assumed that the pointed to object is read when it has no value? Expanded example loosely rewritten from the original library code. --- void GC_addRange(const void * const, __SIZE_TYPE__); struct VoidArray { __SIZE_TYPE__ length; void *ptr; }; // struct Array(T) { #define T int bool isInitialized; VoidArray _data; __SIZE_TYPE__ _capacity; void reserve (__SIZE_TYPE__ elements) { if (!isInitialized) { if (!elements) return; __SIZE_TYPE__ sz; int overflow = __builtin_mul_overflow (elements, sizeof (T), &sz); if (overflow) __builtin_abort (); void *p = __builtin_malloc (sz); if (!p) __builtin_abort (); // static if (hasIndirections!T) { GC_addRange (p, sz); // } _data.ptr = p; _data.length = 0; _capacity = elements; } else { // _data.reserve (elements); } } // };
next prev parent reply other threads:[~2020-09-16 7:41 UTC|newest] Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top 2020-09-08 20:40 [Bug middle-end/96987] New: " ibuclaw at gdcproject dot org 2020-09-09 6:44 ` [Bug middle-end/96987] " rguenth at gcc dot gnu.org 2020-09-09 7:03 ` jakub at gcc dot gnu.org 2020-09-15 16:27 ` msebor at gcc dot gnu.org 2020-09-15 21:01 ` ibuclaw at gdcproject dot org 2020-09-16 7:41 ` ibuclaw at gdcproject dot org [this message] 2020-09-16 14:12 ` msebor at gcc dot gnu.org 2020-09-19 1:02 ` ibuclaw at gdcproject dot 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-96987-4-2vsABZsDGR@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).