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 sell...@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