lambda.c (maybe_add_lambda_conv_op): Only set no_sanitize_undefined if SANITIZE_NULL.
authorJason Merrill <jason@redhat.com>
Wed, 25 Nov 2015 21:34:00 +0000 (16:34 -0500)
committerJason Merrill <jason@gcc.gnu.org>
Wed, 25 Nov 2015 21:34:00 +0000 (16:34 -0500)
* lambda.c (maybe_add_lambda_conv_op): Only set
no_sanitize_undefined if SANITIZE_NULL.

From-SVN: r230908

gcc/cp/ChangeLog
gcc/cp/lambda.c

index 635db4e46e927337debb192c8b81317f5445f2f6..900d8649934e54c874e56cc858746a6dac281326 100644 (file)
@@ -1,5 +1,8 @@
 2015-11-25  Jason Merrill  <jason@redhat.com>
 
+       * lambda.c (maybe_add_lambda_conv_op): Only set
+       no_sanitize_undefined if SANITIZE_NULL.
+
        PR c++/67941
        * lambda.c (maybe_add_lambda_conv_op): Mark _FUN as
        no_sanitize_undefined.
index f9b686b16e82d01c240f03ee5bfbb397f8647fa5..8d1ee14ca39cca73b2f559b38a7a1efa637d6184 100644 (file)
@@ -1053,11 +1053,14 @@ maybe_add_lambda_conv_op (tree type)
   if (generic_lambda_p)
     fn = add_inherited_template_parms (fn, DECL_TI_TEMPLATE (callop));
 
-  /* Don't UBsan this function; we're deliberately calling op() with a null
-     object argument.  */
-  tree attrs = build_tree_list (get_identifier ("no_sanitize_undefined"),
-                               NULL_TREE);
-  cplus_decl_attributes (&fn, attrs, 0);
+  if (flag_sanitize & SANITIZE_NULL)
+    {
+      /* Don't UBsan this function; we're deliberately calling op() with a null
+        object argument.  */
+      tree attrs = build_tree_list (get_identifier ("no_sanitize_undefined"),
+                                   NULL_TREE);
+      cplus_decl_attributes (&fn, attrs, 0);
+    }
 
   add_method (type, fn, NULL_TREE);