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: <gcc-patches at gcc dot gnu dot org>
- Cc: Richard Biener <rguenther at suse dot de>
- Date: Fri, 17 Apr 2015 15:29:24 -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> <1429303946 dot 30498 dot 251 dot camel at ubuntu-sellcey> <alpine dot DEB dot 2 dot 11 dot 1504180009210 dot 1621 at laptop-mg dot saclay dot inria dot fr>
- Reply-to: <sellcey at imgtec dot com>
On Sat, 2015-04-18 at 00:15 +0200, Marc Glisse wrote:
> >
> > 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.
I guess, but it left me very confused because the compiler didn't point
me at the last line, it pointed me at the '*ns = &_dl_ns[nsid]' line.
If there was a lot of stuff in between that line, the line with the call
to the noreturn function, and the ns->ns_loaded line (like there is in
the real glibc), it is very hard to understand what the compiler is
trying to tell me when it only points out the first line as where the
error is.
Steve Ellcey