public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Steve Ellcey <sellcey@imgtec.com>
To: <gcc-patches@gcc.gnu.org>
Cc: Richard Biener <rguenther@suse.de>
Subject: Re: [PATCH] -Warray-bounds TLC
Date: Fri, 17 Apr 2015 22:29:00 -0000	[thread overview]
Message-ID: <1429309764.30498.264.camel@ubuntu-sellcey> (raw)
In-Reply-To: <alpine.DEB.2.11.1504180009210.1621@laptop-mg.saclay.inria.fr>

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

  reply	other threads:[~2015-04-17 22:29 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-04-16 11:55 Richard Biener
2015-04-17 18:01 ` Steve Ellcey
2015-04-17 18:54   ` Richard Biener
2015-04-17 19:08     ` Marc Glisse
2015-04-17 19:53       ` Steve Ellcey
2015-04-17 20:52     ` Steve Ellcey
2015-04-17 21:21       ` Mike Stump
2015-04-17 22:15       ` Marc Glisse
2015-04-17 22:29         ` Steve Ellcey [this message]
2015-04-20  8:05           ` Richard Biener

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1429309764.30498.264.camel@ubuntu-sellcey \
    --to=sellcey@imgtec.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=rguenther@suse.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).