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