[Bug middle-end/48558] -Warray-bounds fails to detect the out of bound array access

hjl.tools at gmail dot com gcc-bugzilla@gcc.gnu.org
Mon Apr 11 18:40:00 GMT 2011


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48558

--- Comment #1 from H.J. Lu <hjl.tools at gmail dot com> 2011-04-11 18:40:07 UTC ---
A testcase:

[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 = 42,
};
static reloc_howto_type elf_howto_table[]=
{
  {
    (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 0;
}
[hjl@gnu-6 bfd]$ /usr/gcc-4.7.0-x32/bin/gcc  -O3 -S -Wall x.c -Warray-bounds 
[hjl@gnu-6 bfd]$



More information about the Gcc-bugs mailing list