This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] -Warray-bounds TLC
- From: Steve Ellcey <sellcey at imgtec dot com>
- To: Richard Biener <rguenther at suse dot de>
- Cc: <gcc-patches at gcc dot gnu dot org>, Marc Glisse <marc dot glisse at inria dot fr>
- Date: Fri, 17 Apr 2015 13:52:26 -0700
- Subject: Re: [PATCH] -Warray-bounds TLC
- Authentication-results: sourceware.org; auth=none
- References: <alpine dot LSU dot 2 dot 11 dot 1504161354290 dot 6786 at zhemvz dot fhfr dot qr> <1429293702 dot 30498 dot 239 dot camel at ubuntu-sellcey> <04757357-8F9D-47B5-95C0-E5C8A546E2EC at suse dot de>
- Reply-to: <sellcey at imgtec dot com>
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