From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id D4B403858D1E; Mon, 6 Feb 2023 15:19:56 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org D4B403858D1E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1675696796; bh=DYsRAslzrAwdWvt+3D8qfD8mL/8nyc7ryY8Qky77RXE=; h=From:To:Subject:Date:In-Reply-To:References:From; b=bPHrMyLlYagMrQGbVmHkstUTYmhYcWXthUv7L6V07r55++fNHtSmp8BYEDSM6DATM JTHxNfoG98elLdJCSlrT6s9aNu4qOCuU8G1isgeQegr6wfuY/HGsSf7NlUKpZp3xTc QASTv8oyF7ZQRFeof6jZ7EGd78YCN+LqbbUmwXfQ= From: "alvaro.begue at gmail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/108667] Spurious "may be used uninitialized [-Wmaybe-uninitialized]" warning Date: Mon, 06 Feb 2023 15:19:56 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: tree-optimization X-Bugzilla-Version: 12.2.0 X-Bugzilla-Keywords: diagnostic X-Bugzilla-Severity: normal X-Bugzilla-Who: alvaro.begue at gmail dot com X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D108667 --- Comment #4 from Alvaro Begue --- Original code: #include #include #include template class Signal { public: using Slot =3D std::function; using FoldingFunction =3D std::function; Signal(FoldingFunction fold, ReturnType initial) : fold(fold), initial(initial) {} void connect(Slot slot) { slots.push_back(slot); } ReturnType operator() (ArgumentTypes... arguments) { ReturnType result =3D initial; for (const auto &slot : slots) result =3D fold(result, slot(arguments...)); return result; } private: std::vector slots; FoldingFunction fold; ReturnType initial; }; int four() { return 4; } int five() { return 5; } int main() { Signal get_total([](int cumulative_value, int new_term){ return cumulative_value + new_term; }, 0); get_total.connect(four); get_total.connect(five); std::cout << get_total() << '\n'; }=