On Thu, Mar 19, 2015 at 07:13:47PM +0100, Marek Polacek wrote: > On Thu, Mar 19, 2015 at 07:05:36PM +0100, Jakub Jelinek wrote: > > I believe cxx_fold_indirect_ref result is not passed through to the > > middle-end, unless it can be folded into a constant. > > > > 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. > > That is rejected even with my patch with: > error: overflow in constant expression [-fpermissive] > and without the patch: > error: ‘*((& s[4]) + 18446744073709551614u)’ is not a constant expression > (a valid constexpr can't have UB).
But s/j = 4/j = 3/ should be valid, don't we reject even that? I mean, isn't the rejection because we fold the - 2 early into sizetype (unsigned) + -2UL? Jakub