public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "m.hekkelman at cmbi dot ru.nl" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c++/51731] code generation bug in negative indices in arrays on 64-bit targets
Date: Tue, 03 Jan 2012 07:45:00 -0000 [thread overview]
Message-ID: <bug-51731-4-JwZDkauJVR@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-51731-4@http.gcc.gnu.org/bugzilla/>
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51731
--- Comment #6 from M.L. Hekkelman <m.hekkelman at cmbi dot ru.nl> 2012-01-03 07:44:55 UTC ---
(In reply to comment #5)
> (In reply to comment #4)
> > Following your logic, if I rewrite the code from:
> >
> > return data.e[-1];
> >
> > to
> >
> > int* ep = data.e;
> > return ep[-1];
> >
> > It would be valid, right? And you still believe the bug report is
> > invalid?
>
> Of course that wouldn't be valid.
> I meant that if you had say array
> type e[10];
> somewhere and
> type *ep = data.e + 9;
> you can then access
> ep[0] + ep[-1] + ep[-9]
> In C++03, please read [expr.add]/5 :
> "If both the pointer operand and the result point to elements of the same array
> object, or one past the last element of the array object, the evaluation shall
> not produce an overflow; otherwise, the behavior is undefined."
I stand corrected.
Still, it would be nice if gcc would then issue a warning instead of only
giving incorrect results when -O3 is specified.
prev parent reply other threads:[~2012-01-03 7:45 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-01-02 12:26 [Bug c++/51731] New: " m.hekkelman at cmbi dot ru.nl
2012-01-02 16:24 ` [Bug c++/51731] " paolo.carlini at oracle dot com
2012-01-02 17:04 ` m.hekkelman at cmbi dot ru.nl
2012-01-02 17:10 ` jakub at gcc dot gnu.org
2012-01-02 19:08 ` m.hekkelman at cmbi dot ru.nl
2012-01-02 19:32 ` jakub at gcc dot gnu.org
2012-01-03 7:45 ` m.hekkelman at cmbi dot ru.nl [this message]
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=bug-51731-4-JwZDkauJVR@http.gcc.gnu.org/bugzilla/ \
--to=gcc-bugzilla@gcc.gnu.org \
--cc=gcc-bugs@gcc.gnu.org \
/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).