diff options
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/cp/ChangeLog | 3 | ||||
-rw-r--r-- | gcc/cp/lambda.c | 13 |
2 files changed, 11 insertions, 5 deletions
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 <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. 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); |