From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 584073858C53; Tue, 28 Mar 2023 07:43:12 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 584073858C53 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1679989392; bh=gK5gO9A8nDWhUlIt98engZLifeceuZhzyNmXXsRv5qw=; h=From:To:Subject:Date:From; b=dQZ3O1+UUx7+eWyoNFUc15CtrgXTdsxJWzfqi5KRitpek3BY/XJYjAdoBz6XJ9vM2 E3zNuUaZlC7ugwtbXCaZn/SG0YiBUF+GqwH+IlAC3UJy1TAa24nEZflnXKSXO3RuQX mGsIPijuX9AjmM8GfQcJCvYh0BZQWU50S0fLuQXs= From: "shaohua.li at inf dot ethz.ch" To: gcc-bugs@gcc.gnu.org Subject: [Bug sanitizer/109313] New: Incorrect line number in Use-After-Scope report Date: Tue, 28 Mar 2023 07:43:11 +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: 13.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: shaohua.li at inf dot ethz.ch 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=3D109313 Bug ID: 109313 Summary: Incorrect line number in Use-After-Scope report Product: gcc Version: 13.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: sanitizer Assignee: unassigned at gcc dot gnu.org Reporter: shaohua.li at inf dot ethz.ch 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: --- For the following code, Asan reports an incorrect line number at -O1 and ab= ove.=20 Compiler explorer: https://godbolt.org/z/KsroWf9M6 % cat -n a.c 1 int a, b; 2 int main() { 3 int *c=3D&a; 4 b =3D 0; 5 for (; b < 1; b++) { 6 int d=3D1; 7 c =3D &d; 8 if (a) 9 break; 10 } 11 if (*c) { 12 int e[1]=3D{2}; 13 return e[0]; 14 } 15 } % % gcc-tk -O0 -fsanitize=3Daddress a.c && ./a.out =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D =3D=3D1=3D=3DERROR: AddressSanitizer: stack-use-after-scope on address 0x7f= 2293700030 at pc 0x0000004012de bp 0x7ffca6ef0690 sp 0x7ffca6ef0688 READ of size 4 at 0x7f2293700030 thread T0 #0 0x4012dd in main /a.c:11 ... % % gcc-tk -O1 -fsanitize=3Daddress a.c && ./a.out =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D =3D=3D1=3D=3DERROR: AddressSanitizer: stack-use-after-scope on address 0x7f= 7c4d200020 at pc 0x0000004011ee bp 0x7fff0179f250 sp 0x7fff0179f248 READ of size 4 at 0x7f7c4d200020 thread T0 #0 0x4011ed in main /a.c:5 ... %=