re PR sanitizer/88901 (ICE when using -fsanitize=pointer-compare)
[gcc.git] / gcc / cp / typeck.c
index 47e407d1faae97a380b6253f12039702ecd60434..ec722a360357d2a4d4aa5883a23928deb0d69401 100644 (file)
@@ -5233,6 +5233,7 @@ cp_build_binary_op (const op_location_t &location,
        }
 
       if ((code0 == POINTER_TYPE || code1 == POINTER_TYPE)
+         && !processing_template_decl
          && sanitize_flags_p (SANITIZE_POINTER_COMPARE))
        {
          op0 = save_expr (op0);
@@ -5650,7 +5651,8 @@ pointer_diff (location_t loc, tree op0, tree op1, tree ptrtype,
   else
     inttype = restype;
 
-  if (sanitize_flags_p (SANITIZE_POINTER_SUBTRACT))
+  if (!processing_template_decl
+      && sanitize_flags_p (SANITIZE_POINTER_SUBTRACT))
     {
       op0 = save_expr (op0);
       op1 = save_expr (op1);