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: [PATCH] c++/60760 - arithmetic on null pointers should not be allowed in constant expressions


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.

Jason


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