This is the mail archive of the gcc-patches@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]

Re: [PATCH] -Warray-bounds TLC


As a follow-up, I got the same error with dl-close.c from glibc and
assumed it was the same type of code but when I looked at it and cut it
down I got this code and error.  This seems more like a real GCC error
(in that it should not be warning).  Note that I only get the error when
bad is declared as 'noreturn'.

Steve Ellcey
sellcey@imgtec.com



extern void bad (const char *__assertion)  __attribute__ ((__noreturn__));
struct link_map { long int l_ns; };
extern struct link_namespaces
  {
    unsigned int _ns_nloaded;
  } _dl_ns[1];
void _dl_close_worker (struct link_map *map)
{
  long int nsid = map->l_ns;
  struct link_namespaces *ns = &_dl_ns[nsid];
  (nsid != 0) ? (void) (0) : bad ("nsid != 0");
  --ns->_ns_nloaded;
}



% inst*/bin/*-gcc -O2 -Wall -Werror x.c
x.c: In function '_dl_close_worker':
x.c:10:39: error: array subscript is outside array bounds [-Werror=array-bounds]
   struct link_namespaces *ns = &_dl_ns[nsid];
                                       ^
x.c:10:39: error: array subscript is outside array bounds [-Werror=array-bounds]
cc1: all warnings being treated as errors


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