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


On Fri, 17 Apr 2015, Steve Ellcey wrote:

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;
}

It looks close enough to me. The actual access to _dl_ns[nsid] only ever happens for an index that is out of range. The last line of the function can never make sense (unreachable or undefined behavior), it is good that the compiler tells you about it.

--
Marc Glisse


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