On Mon, Jul 18, 2016 at 6:15 PM, Martin Sebor <mse...@gmail.com> wrote: > On 07/18/2016 11:51 AM, Jason Merrill wrote: >> >> On 07/06/2016 06:20 PM, Martin Sebor wrote: >>> >>> @@ -2911,6 +2923,14 @@ cxx_eval_indirect_ref (const constexpr_ctx >>> *ctx, tree t, >>> if (*non_constant_p) >>> return t; >>> >>> + if (integer_zerop (op0)) >>> + { >>> + if (!ctx->quiet) >>> + error ("dereferencing a null pointer"); >>> + *non_constant_p = true; >>> + return t; >>> + } >> >> I'm skeptical of checking this here, since *p is valid for null p; &*p >> is even a constant expression. And removing this hunk doesn't seem to >> break any of your tests. >> >> OK with that hunk removed. > > With it removed the constexpr-nullptr-2.C test fails on line 64: > > constexpr const int *pi0 = &pa2->pa1->pa0->i; // { dg-error "null > pointer|not a constant" } > > Here, pa2 and pa1 are non-null but pa0 is null.
It doesn't fail for me; that line hits the error in cxx_eval_component_reference. I'm only talking about removing the cxx_eval_indirect_ref hunk. Jason