From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 116A63858289; Fri, 26 May 2023 14:43:38 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 116A63858289 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1685112219; bh=cyskPqH6es+sAAYzwcSBVo9WkrH/+/Tiv7zLlCCHuD0=; h=From:To:Subject:Date:From; b=G7qaQjmgikPyB8mfro1yUovOiaNL+gIwyLwOWRrD6UWCGTUjwFc/x7Rt9ZpVHEM2v 77VzVtoJ0ufSJgUAd0qs2AVxTs9bV1oDGOYx0JFxBHVZ0zPEbNKDIY3e8BD4ui9UtQ siHoRnSVgUrEDbA0WKUmWBV5wuyTEZyrHvoT/TSo= From: "igkper at gmail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug sanitizer/109991] New: stack-use-after-scope Date: Fri, 26 May 2023 14:43:38 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: sanitizer X-Bugzilla-Version: 14.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: igkper 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: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter cc target_milestone Message-ID: 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=3D109991 Bug ID: 109991 Summary: stack-use-after-scope Product: gcc Version: 14.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: sanitizer Assignee: unassigned at gcc dot gnu.org Reporter: igkper at gmail dot com CC: dodji at gcc dot gnu.org, dvyukov at gcc dot gnu.org, jakub at gcc dot gnu.org, kcc at gcc dot gnu.org, marxi= n at gcc dot gnu.org Target Milestone: --- Hi, I believe the below code should result in sanitizer complaining about stack-use-after-scope, but it does not. I've noted that clang catches this = but not gcc. I've annotated where I've noted it seems to depend on whether or n= ot constexpr is used. See https://godbolt.org/z/Y3YKcfGda. using T =3D int; struct Wrap { T const& v; // Shouldn't extend lifetime of temporary constexpr Wrap(T const& in) : v{in} {} }; struct BadWrapUse final { T i{}; constexpr BadWrapUse() // issue not caught with constexpr // BadWrapUse() // issue caught without constexpr { Wrap w{T{}}; // temporary T's lifetime ends after this expression i =3D w.v; // This should lead to stack-use-after-scope. } }; int main() { BadWrapUse c; }=