1 //===----------------------------------------------------------------------===// 2 // 3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4 // See https://llvm.org/LICENSE.txt for license information. 5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 // 7 //===----------------------------------------------------------------------===// 8 9 // Address Sanitizer doesn't instrument weak symbols on Linux. When a key 10 // function is defined for bad_function_call's vtable, its typeinfo and vtable 11 // will be defined as strong symbols in the library and weak symbols in other 12 // translation units. Only the strong symbol will be instrumented, increasing 13 // its size (due to the redzone) and leading to a serious ODR violation 14 // resulting in a crash. 15 // Some relevant bugs: 16 // https://github.com/google/sanitizers/issues/1017 17 // https://github.com/google/sanitizers/issues/619 18 // https://github.com/google/sanitizers/issues/398 19 // https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68016 20 // UNSUPPORTED: c++03, asan 21 // XFAIL: LIBCXX-AIX-FIXME 22 23 // <functional> 24 25 // template<CopyConstructible Fn, CopyConstructible... Types> 26 // unspecified bind(Fn, Types...); 27 // template<Returnable R, CopyConstructible Fn, CopyConstructible... Types> 28 // unspecified bind(Fn, Types...); 29 30 // https://llvm.org/PR16385 31 32 #include <functional> 33 #include <cmath> 34 #include <cassert> 35 36 #include "test_macros.h" 37 38 float _pow(float a, float b) 39 { 40 return std::pow(a, b); 41 } 42 43 int main(int, char**) 44 { 45 std::function<float(float, float)> fnc = _pow; 46 auto task = std::bind(fnc, 2.f, 4.f); 47 auto task2(task); 48 assert(task() == 16); 49 assert(task2() == 16); 50 51 return 0; 52 } 53