This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: C++ PATCH for c++/65398 (valid constexpr rejected)


On 03/20/2015 10:59 AM, Jakub Jelinek wrote:
On Fri, Mar 20, 2015 at 10:53:50AM -0400, Jason Merrill wrote:
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.

It is taking address of two past the end though - &s[3] is fine, sure.
But &s[4] is invalid already.

&s[3] is the address of the terminal \0.

Jason


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]