This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug libgcc/63832] New: [5.0 Regression] crtstuff.c:400:19: warning: array subscript is above array bounds [-Warray-bounds]


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

            Bug ID: 63832
           Summary: [5.0 Regression] crtstuff.c:400:19: warning: array
                    subscript is above array bounds [-Warray-bounds]
           Product: gcc
           Version: 5.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libgcc
          Assignee: unassigned at gcc dot gnu.org
          Reporter: ubizjak at gmail dot com
            Target: x86

Recently, gcc bootstrap starts to emit following warning when building CRT
support:

../../../gcc-svn/trunk/libgcc/crtstuff.c: In function â__do_global_dtors_auxâ:
../../../gcc-svn/trunk/libgcc/crtstuff.c:400:19: warning: array subscript is
above array bounds [-Warray-bounds]
  f = __DTOR_LIST__[++dtor_idx];

where:

#ifdef DTOR_LIST_BEGIN
DTOR_LIST_BEGIN;
#elif defined(__LIBGCC_DTORS_SECTION_ASM_OP__)
asm (__LIBGCC_DTORS_SECTION_ASM_OP__);
STATIC func_ptr __DTOR_LIST__[1]
  __attribute__ ((aligned(sizeof(func_ptr))))
  = { (func_ptr) (-1) };
#else
STATIC func_ptr __DTOR_LIST__[1]
  __attribute__((section(".dtors"), aligned(sizeof(func_ptr))))
  = { (func_ptr) (-1) };
#endif /* __DTOR_LIST__ alternatives */

...

#ifdef FINI_ARRAY_SECTION_ASM_OP
  /* If we are using .fini_array then destructors will be run via that
     mechanism.  */
#elif defined(HIDDEN_DTOR_LIST_END)
  {
    /* Safer version that makes sure only .dtors function pointers are
       called even if the static variable is maliciously changed.  */
    extern func_ptr __DTOR_END__[] __attribute__((visibility ("hidden")));
    static size_t dtor_idx;
    const size_t max_idx = __DTOR_END__ - __DTOR_LIST__ - 1;
    func_ptr f;

    while (dtor_idx < max_idx)
      {
    f = __DTOR_LIST__[++dtor_idx];
    f ();
      }
  }
#else /* !defined (FINI_ARRAY_SECTION_ASM_OP) */
  {
    static func_ptr *p = __DTOR_LIST__ + 1;
    func_ptr f;

    while ((f = *p))
      {
    p++;
    f ();
      }
  }
#endif /* !defined(FINI_ARRAY_SECTION_ASM_OP) */

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]