From: Jason Merrill Date: Wed, 25 Nov 2015 21:34:00 +0000 (-0500) Subject: lambda.c (maybe_add_lambda_conv_op): Only set no_sanitize_undefined if SANITIZE_NULL. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=75729cff1ebd87576916e99cd539b0c9223e5d99;p=gcc.git lambda.c (maybe_add_lambda_conv_op): Only set no_sanitize_undefined if SANITIZE_NULL. * lambda.c (maybe_add_lambda_conv_op): Only set no_sanitize_undefined if SANITIZE_NULL. From-SVN: r230908 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 635db4e46e9..900d8649934 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,8 @@ 2015-11-25 Jason Merrill + * 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. diff --git a/gcc/cp/lambda.c b/gcc/cp/lambda.c index f9b686b16e8..8d1ee14ca39 100644 --- a/gcc/cp/lambda.c +++ b/gcc/cp/lambda.c @@ -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);