public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
From: Richard Biener <rguenth@gcc.gnu.org>
To: gcc-cvs@gcc.gnu.org
Subject: [gcc r13-2776] tree-optimization/102801 - testcase for uninit diagnostic
Date: Thu, 22 Sep 2022 13:19:58 +0000 (GMT)	[thread overview]
Message-ID: <20220922131958.52269385C30F@sourceware.org> (raw)

https://gcc.gnu.org/g:44dba051d72587828882cbb31118934a4fb06c1a

commit r13-2776-g44dba051d72587828882cbb31118934a4fb06c1a
Author: Richard Biener <rguenther@suse.de>
Date:   Thu Sep 22 15:18:47 2022 +0200

    tree-optimization/102801 - testcase for uninit diagnostic
    
    The following testcase is fixed in GCC 12+
    
            PR tree-optimization/102801
    gcc/testsuite/
            * g++.dg/warn/Wuninitialized-33.C: New testcase.

Diff:
---
 gcc/testsuite/g++.dg/warn/Wuninitialized-33.C | 55 +++++++++++++++++++++++++++
 1 file changed, 55 insertions(+)

diff --git a/gcc/testsuite/g++.dg/warn/Wuninitialized-33.C b/gcc/testsuite/g++.dg/warn/Wuninitialized-33.C
new file mode 100644
index 00000000000..1bb0639ee30
--- /dev/null
+++ b/gcc/testsuite/g++.dg/warn/Wuninitialized-33.C
@@ -0,0 +1,55 @@
+// PR102801
+// { dg-do compile }
+// { dg-require-effective-target c++17 }
+// { dg-options "-O2 -Wall" }
+
+#include <algorithm>
+#include <memory>
+#include <optional>
+#include <string>
+#include <utility>
+#include <vector>
+
+class C {
+    bool b{}; // { dg-bogus "uninitialized" }
+
+    struct Shared {};
+    using SharedPtr = std::shared_ptr<const Shared>;
+
+    SharedPtr shared;
+
+public:
+    C() = delete;
+    C(bool bIn) : b(bIn) {}
+    ~C();
+    int someMethod() const;
+};
+
+using OptC = std::optional<C>;
+
+class C2 {
+    OptC c;
+public:
+    C2() = default;
+    C2(const C &cIn) : c(cIn) {}
+    ~C2();
+    void operator()() const;
+    void swap(C2 &o) { std::swap(c, o.c); }
+};
+
+
+template <typename T>
+class Q {
+    std::vector<T> queue;
+public:
+    void Add(std::vector<T> &items) {
+        for (T & item : items) {
+            queue.push_back(T());
+            item.swap(queue.back());
+        }
+    }
+    void Exec();
+};
+
+extern void foo(Q<C2> & q, std::vector<C2> &items);
+void foo(Q<C2> & q, std::vector<C2> &items) { q.Add(items); q.Exec(); }

                 reply	other threads:[~2022-09-22 13:19 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=20220922131958.52269385C30F@sourceware.org \
    --to=rguenth@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: link
Be 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).