public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Jason Merrill <jason@redhat.com>
To: Jakub Jelinek <jakub@redhat.com>,
	       Richard Biener <richard.guenther@gmail.com>
Cc: Marek Polacek <polacek@redhat.com>,
	GCC Patches <gcc-patches@gcc.gnu.org>
Subject: Re: C++ PATCH for c++/65398 (valid constexpr rejected)
Date: Fri, 20 Mar 2015 14:53:00 -0000	[thread overview]
Message-ID: <550C347E.2070801@redhat.com> (raw)
In-Reply-To: <20150319180536.GA1746@tucnak.redhat.com>

On 03/19/2015 02:05 PM, Jakub Jelinek wrote:
> Though, a question is if we do (or, if we don't and should) reject say
> constexpr char s[] = "abc";
> constexpr int j = 4;
> constexpr char c = *(&s[j] - 2);
> because there was out of bound access in there.

I don't see an out-of-bound access in this example; taking the address 
of one-past-the-end is OK as long as you don't try to access through it.

> Unfortunately we reject even that (regardless the patch), and yeah, it's
> because of how POINTER_PLUS_EXPR uses sizetype as a type of the second operand.

This seems like something to fix in this patch.

> +	      tree t = fold_convert_loc (loc, TREE_TYPE (op01),
> +					 TREE_OPERAND (op00, 1));
> +	      t = size_binop_loc (loc, PLUS_EXPR, op01, t);

This seems to be assuming that the elements are size 1.

Jason

  parent reply	other threads:[~2015-03-20 14:53 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-03-13 14:41 Marek Polacek
2015-03-18 10:08 ` Richard Biener
2015-03-19 18:05   ` Jakub Jelinek
2015-03-19 18:13     ` Marek Polacek
2015-03-19 18:17       ` Jakub Jelinek
2015-03-19 18:33         ` Marek Polacek
2015-03-20 14:53     ` Jason Merrill [this message]
2015-03-20 14:59       ` Jakub Jelinek
2015-03-20 15:03         ` Jason Merrill
2015-03-20 15:11           ` Jakub Jelinek
2015-03-20 15:15             ` Jason Merrill
2015-03-20 15:28               ` Jakub Jelinek
2015-03-20 20:57       ` C++ PATCH for c++/65398 (valid constexpr rejected) (take 2) Marek Polacek
2015-03-20 21:04         ` Jakub Jelinek
2015-03-20 21:10           ` Jason Merrill

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=550C347E.2070801@redhat.com \
    --to=jason@redhat.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=jakub@redhat.com \
    --cc=polacek@redhat.com \
    --cc=richard.guenther@gmail.com \
    /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).