public inbox for gcc-cvs@sourceware.org help / color / mirror / Atom feed
From: Martin Sebor <msebor@gcc.gnu.org> To: gcc-cvs@gcc.gnu.org Subject: [gcc r11-8162] PR tree-optimization/82800 - Incorrect warning on "may be used uninitialized in variadic template co Date: Tue, 13 Apr 2021 20:55:20 +0000 (GMT) [thread overview] Message-ID: <20210413205520.3457E39551D7@sourceware.org> (raw) https://gcc.gnu.org/g:af7128621e54f04b90589bb0c3e1ef271c239265 commit r11-8162-gaf7128621e54f04b90589bb0c3e1ef271c239265 Author: Martin Sebor <msebor@redhat.com> Date: Tue Apr 13 14:53:26 2021 -0600 PR tree-optimization/82800 - Incorrect warning on "may be used uninitialized in variadic template code gcc/testsuite/ChangeLog: PR tree-optimization/82800 * g++.dg/warn/uninit-pr82800.C: New test. Diff: --- gcc/testsuite/g++.dg/warn/uninit-pr82800.C | 43 ++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/gcc/testsuite/g++.dg/warn/uninit-pr82800.C b/gcc/testsuite/g++.dg/warn/uninit-pr82800.C new file mode 100644 index 00000000000..dc3ce5d89e3 --- /dev/null +++ b/gcc/testsuite/g++.dg/warn/uninit-pr82800.C @@ -0,0 +1,43 @@ +/* PR 82800 - Incorrect warning on "may be used uninitialized in + variadic template code + { dg-do compile { target c++11 } } + { dg-options "-O2 -Wall" } */ + +typedef __SIZE_TYPE__ size_t; + +extern "C" int rand (); + +struct Maker +{ + double makeConst() + { + return pick<double>(0, 0, 0, 0, 0, 0, 1); // { dg-bogus "uninitialized" } + } + + template<typename T, typename... Args> + T pick(T first, Args... args) + { + return pickGivenNum<T>(rand(), first, args...); + } + + template<typename T> + T pickGivenNum(size_t num, T first) + { + if (num != 0) __builtin_abort(); + return first; + } + + template<typename T, typename... Args> + T pickGivenNum(size_t num, T first, Args... args) + { + if (num == 0) return first; + return pickGivenNum<T>(num - 1, args...); + } +}; + +int main () +{ + Maker maker; + maker.makeConst(); + maker.makeConst(); +}
reply other threads:[~2021-04-13 20:55 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20210413205520.3457E39551D7@sourceware.org \ --to=msebor@gcc.gnu.org \ --cc=gcc-cvs@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).