From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id E98B13858C66; Wed, 26 Apr 2023 12:46:41 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org E98B13858C66 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1682513201; bh=IhlFQMnbQKv6WCPEKFpxNiCH2f/HSALEY9nXZK+g9Eg=; h=From:To:Subject:Date:In-Reply-To:References:From; b=H26zuzzqQFFd6MSl9ww/K9VUAZ+yDNMZhcjUt8C0wqly/h6yzLLAIN4smgyej+yAm pjxLRfMcaGykte7WxDAXh1kCAS9G0TuFcjBVcDc4kDkIzbgROBYW2tt7f+U6+QIuuI 4e7hMWA639ARrih5FzJ83IcqUKjVe4bkW6YTKxM8= From: "fiesh at zefix dot tv" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/88804] incorrect unused but set static variable in templated lambda Date: Wed, 26 Apr 2023 12:46:40 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c++ X-Bugzilla-Version: 8.2.1 X-Bugzilla-Keywords: diagnostic X-Bugzilla-Severity: normal X-Bugzilla-Who: fiesh at zefix dot tv X-Bugzilla-Status: NEW 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: cc 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=3D88804 fiesh at zefix dot tv changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |fiesh at zefix dot tv --- Comment #7 from fiesh at zefix dot tv --- I suppose this snippet also exhibits this bug here? template struct IntegerSequence {}; template struct IntegralConstant { constexpr auto operator()() const { return i; } }; template constexpr void apply(F const &f, IntegerSequence) { (f(IntegralConstant{}), ...); } template constexpr void constexpr_foreach(F const &= f) { apply(f, IntegerSequence<0>{}); } int main() { static int i[1] =3D {42}; int j{}; constexpr_foreach<1>([&j](auto const index) { j +=3D i[index()]; }); return j; }=