From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 131C23858D33; Mon, 28 Aug 2023 07:44:56 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 131C23858D33 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1693208696; bh=uku6ujkmdKhjHAJmmp2h/A/WtsRZLzr8TxmjeEpn6IE=; h=From:To:Subject:Date:In-Reply-To:References:From; b=LXIwHJObXWFR+m7VjzEQo5rhsgtm5Dy1uhMA9MG4E3HUCGXMLkwMQj0dXEqnzuvxl HN3iTJQf3PzPkmEHR+1wylpuRsfY3i87sbuf3lVam9/M5oQLxC8hML0IQDs667ciJs vwDralx6BgHKMUHyAUjRG/AdkNj5uzRWxtxEm6UA= From: "lehua.ding at rivai dot ai" To: gcc-bugs@gcc.gnu.org Subject: [Bug c/111211] No warning for iterator going out of scope Date: Mon, 28 Aug 2023 07:44:55 +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: 14.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: lehua.ding at rivai dot ai 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=3D111211 --- Comment #1 from Lehua Ding --- Reproduce: Compile Command: gcc -O3 -Wall -Wextra C Code: ``` #include int foo (uint64_t ddr0_addr_access) { uint64_t check[1] =3D {0}; for (int k =3D 0; k < 7; k +=3D 1) { asm volatile ("nop" : "=3Dr"(check[k]) : "r"(ddr0_addr_access)); } return 0; } int foo2 (uint64_t ddr0_addr_access) { uint64_t check[1] =3D {0}; for (int k =3D 0; k < 8; k +=3D 1) { asm volatile ("nop" : "=3Dr"(check[k]) : "r"(ddr0_addr_access)); } return 0; } ``` Output: : In function 'foo': :9:41: warning: array subscript 1 is above array bounds of 'uint64_t[1]' {aka 'long unsigned int[1]'} [-Warray-bounds=3D] 9 | asm volatile ("nop" : "=3Dr"(check[k]) : "r"(ddr0_addr_acce= ss)); | ~~~~~^~~ :5:14: note: while referencing 'check' 5 | uint64_t check[1] =3D {0}; | ^~~~~ :9:41: warning: array subscript 2 is above array bounds of 'uint64_t[1]' {aka 'long unsigned int[1]'} [-Warray-bounds=3D] 9 | asm volatile ("nop" : "=3Dr"(check[k]) : "r"(ddr0_addr_acce= ss)); | ~~~~~^~~ :5:14: note: while referencing 'check' 5 | uint64_t check[1] =3D {0}; | ^~~~~ :9:41: warning: array subscript 3 is above array bounds of 'uint64_t[1]' {aka 'long unsigned int[1]'} [-Warray-bounds=3D] 9 | asm volatile ("nop" : "=3Dr"(check[k]) : "r"(ddr0_addr_acce= ss)); | ~~~~~^~~ :5:14: note: while referencing 'check' 5 | uint64_t check[1] =3D {0}; | ^~~~~ :9:41: warning: array subscript 4 is above array bounds of 'uint64_t[1]' {aka 'long unsigned int[1]'} [-Warray-bounds=3D] 9 | asm volatile ("nop" : "=3Dr"(check[k]) : "r"(ddr0_addr_acce= ss)); | ~~~~~^~~ :5:14: note: while referencing 'check' 5 | uint64_t check[1] =3D {0}; | ^~~~~ :9:41: warning: array subscript 5 is above array bounds of 'uint64_t[1]' {aka 'long unsigned int[1]'} [-Warray-bounds=3D] 9 | asm volatile ("nop" : "=3Dr"(check[k]) : "r"(ddr0_addr_acce= ss)); | ~~~~~^~~ :5:14: note: while referencing 'check' 5 | uint64_t check[1] =3D {0}; | ^~~~~ :9:41: warning: array subscript 6 is above array bounds of 'uint64_t[1]' {aka 'long unsigned int[1]'} [-Warray-bounds=3D] 9 | asm volatile ("nop" : "=3Dr"(check[k]) : "r"(ddr0_addr_acce= ss)); | ~~~~~^~~ :5:14: note: while referencing 'check' 5 | uint64_t check[1] =3D {0}; | ^~~~~ Compiler returned: 0=