Commit 5546e160 by Jason Merrill Committed by Jason Merrill

re PR sanitizer/67941 (calls on function pointer from a captureless lambda cause ubsan warning)

	PR c++/67941
	* lambda.c (maybe_add_lambda_conv_op): Mark _FUN as
	no_sanitize_undefined.

From-SVN: r230897
parent 917124c3
2015-11-25 Jason Merrill <jason@redhat.com> 2015-11-25 Jason Merrill <jason@redhat.com>
PR c++/67941
* lambda.c (maybe_add_lambda_conv_op): Mark _FUN as
no_sanitize_undefined.
* cp-ubsan.c (cp_ubsan_instrument_vptr_p): Use * cp-ubsan.c (cp_ubsan_instrument_vptr_p): Use
do_ubsan_in_current_function. do_ubsan_in_current_function.
......
...@@ -1053,6 +1053,12 @@ maybe_add_lambda_conv_op (tree type) ...@@ -1053,6 +1053,12 @@ maybe_add_lambda_conv_op (tree type)
if (generic_lambda_p) if (generic_lambda_p)
fn = add_inherited_template_parms (fn, DECL_TI_TEMPLATE (callop)); 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);
add_method (type, fn, NULL_TREE); add_method (type, fn, NULL_TREE);
if (nested) if (nested)
......
// PR c++/67941
// { dg-do run { target c++11 } }
// { dg-options -fsanitize=null }
int main(){ (+[](){})(); }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment