public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug middle-end/102037] New: False positive in -Warray-bounds
@ 2021-08-24 11:34 huntazhang at tencent dot com
  2021-08-24 16:03 ` [Bug middle-end/102037] " pinskia at gcc dot gnu.org
  0 siblings, 1 reply; 2+ messages in thread
From: huntazhang at tencent dot com @ 2021-08-24 11:34 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102037

            Bug ID: 102037
           Summary: False positive in -Warray-bounds
           Product: gcc
           Version: 12.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: middle-end
          Assignee: unassigned at gcc dot gnu.org
          Reporter: huntazhang at tencent dot com
  Target Milestone: ---

Created attachment 51351
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=51351&action=edit
test code

[root@VM-209-165-centos ~]# gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/libexec/gcc/x86_64-linux-gnu/12.0.0/lto-wrapper
Target: x86_64-linux-gnu
Configured with: ../configure --enable-language=c,c++ --prefix=/usr
--program-suffix=-12 --program-prefix=x86_64-linux-gnu --enable-plugin
--disable-multilib --build=x86_64-linux-gnu --target=x86_64-linux-gnu
--enable-vtable-verify --disable-bootstrap
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 12.0.0 20210823 (experimental) (GCC) 
[root@VM-209-165-centos ~]# gcc -O2 -Wall array-bound-index.c 
In function 'rdfs8',
    inlined from 'main' at array-bound-index.c:13:2:
array-bound-index.c:7:9: warning: array subscript 0 is outside array bounds of
'u8[0]' {aka 'unsigned char[]'} [-Warray-bounds]
    7 |         asm volatile("movb %%fs:%1,%0" : "=q" (v) : "m" (*(u8 *)addr));

here is my debug log 
Breakpoint 1, compute_objsize_r (ptr=0x7ffff74593a8, ostype=0,
pref=0x7fffffffd730, snlim=..., qry=0x7fffffffd5f0) at
../../gcc/pointer-query.cc:1587
1587      STRIP_NOPS (ptr);
(gdb) p debug(ptr)
1160B
$2 = void
(gdb) n
1589      const bool addr = TREE_CODE (ptr) == ADDR_EXPR;
(gdb) 
1590      if (addr)
(gdb) n
1596      if (DECL_P (ptr))
(gdb) n
1621      const tree_code code = TREE_CODE (ptr);
(gdb) n
1622      range_query *const rvals = qry ? qry->rvals : NULL;
(gdb) n
1624      if (code == BIT_FIELD_REF)
(gdb) 
1635      if (code == COMPONENT_REF)
(gdb) n
1702      if (code == ARRAY_REF)
(gdb) 
1705      if (code == MEM_REF)
(gdb) 
1708      if (code == TARGET_MEM_REF)
(gdb) 
1720      if (code == INTEGER_CST)
(gdb) 
1726          if (integer_zerop (ptr))
(gdb) n
1729            pref->sizrng[0] = pref->sizrng[1] = 0;
(gdb) p gimple_debug_cfg(TDF_DETAILS)

;; Function main (main, funcdef_no=1, decl_uid=1948, cgraph_uid=2,
symbol_order=1) (executed once)

;; 
3 basic blocks, 2 edges, last basic block 3.

;; basic block 2, loop depth 0, count 1073741824 (estimated locally), maybe hot
;;  prev block 0, next block 1, flags: (NEW, REACHABLE, VISITED)
;;  pred:       ENTRY [always]  count:1073741824 (estimated locally)
(FALLTHRU,EXECUTABLE)
;;  succ:       EXIT [always]  count:1073741824 (estimated locally)
(EXECUTABLE)

int main ()
{
  u8 v;

;;   basic block 2, loop depth 0, count 1073741824 (estimated locally), maybe
hot
;;    prev block 0, next block 1, flags: (NEW, REACHABLE, VISITED)
;;    pred:       ENTRY [always]  count:1073741824 (estimated locally)
(FALLTHRU,EXECUTABLE)
  __asm__ __volatile__("movb %%fs:%1,%0" : "=q" v_2 : "m" MEM[(u8 *)1160B]);
  return 0;
;;    succ:       EXIT [always]  count:1073741824 (estimated locally)
(EXECUTABLE)

}


$3 = void
(gdb) p debug(ptr)
1160B
$4 = void
(gdb) frame 1
#1  0x000000000126212c in handle_mem_ref (mref=0x7ffff7475168, ostype=0,
pref=0x7fffffffd730, snlim=..., qry=0x7fffffffd5f0) at
../../gcc/pointer-query.cc:1551
1551      if (!compute_objsize_r (mrefop, ostype, pref, snlim, qry))
(gdb) p debug(mref)
MEM[(u8 *)1160B]
$5 = void
(gdb)

^ permalink raw reply	[flat|nested] 2+ messages in thread

* [Bug middle-end/102037] False positive in -Warray-bounds
  2021-08-24 11:34 [Bug middle-end/102037] New: False positive in -Warray-bounds huntazhang at tencent dot com
@ 2021-08-24 16:03 ` pinskia at gcc dot gnu.org
  0 siblings, 0 replies; 2+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-08-24 16:03 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102037

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |DUPLICATE
             Status|UNCONFIRMED                 |RESOLVED

--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Dup of bug 99578.

*** This bug has been marked as a duplicate of bug 99578 ***

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-08-24 16:03 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-24 11:34 [Bug middle-end/102037] New: False positive in -Warray-bounds huntazhang at tencent dot com
2021-08-24 16:03 ` [Bug middle-end/102037] " pinskia at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).