From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 32607 invoked by alias); 11 Apr 2011 19:10:04 -0000 Received: (qmail 32598 invoked by uid 22791); 11 Apr 2011 19:10:03 -0000 X-SWARE-Spam-Status: No, hits=-2.8 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_00 X-Spam-Check-By: sourceware.org Received: from localhost (HELO gcc.gnu.org) (127.0.0.1) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 11 Apr 2011 19:09:56 +0000 From: "hjl.tools at gmail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug middle-end/48558] -Warray-bounds fails to detect the out of bound array access X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: middle-end X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: hjl.tools at gmail dot com X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Date: Mon, 11 Apr 2011 19:10:00 -0000 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org X-SW-Source: 2011-04/txt/msg01126.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D48558 --- Comment #2 from H.J. Lu 2011-04-11 19:09:5= 4 UTC --- A simple change from return &elf_howto_table[R_386_IRELATIVE]; to return elf_howto_table[R_386_IRELATIVE]; makes GCC to warn: [hjl@gnu-6 bfd]$ cat x.c enum bfd_reloc_code_real { BFD_RELOC_386_IRELATIVE }; typedef enum bfd_reloc_code_real bfd_reloc_code_real_type; typedef const struct reloc_howto_struct reloc_howto_type; struct reloc_howto_struct { unsigned int type; }; enum elf_i386_reloc_type { R_386_IRELATIVE =3D 42, }; static reloc_howto_type elf_howto_table[]=3D { { (unsigned) R_386_IRELATIVE } }; reloc_howto_type elf_i386_reloc_type_lookup (bfd_reloc_code_real_type code) { switch (code) { case BFD_RELOC_386_IRELATIVE: return elf_howto_table[R_386_IRELATIVE]; default: break; } return elf_howto_table[0]; } [hjl@gnu-6 bfd]$ /usr/gcc-4.7.0-x32/bin/gcc -O3 -S -Wall x.c -Warray-bound= s=20 x.c: In function =E2=80=98elf_i386_reloc_type_lookup=E2=80=99: x.c:25:29: warning: array subscript is above array bounds [-Warray-bounds] [hjl@gnu-6 bfd]$