15a83710eSEric Fiselier //===----------------------------------------------------------------------===//
25a83710eSEric Fiselier //
357b08b09SChandler Carruth // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
457b08b09SChandler Carruth // See https://llvm.org/LICENSE.txt for license information.
557b08b09SChandler Carruth // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
65a83710eSEric Fiselier //
75a83710eSEric Fiselier //===----------------------------------------------------------------------===//
85a83710eSEric Fiselier
9434dc0a5SKonstantin Varlamov // Address Sanitizer doesn't instrument weak symbols on Linux. When a key
10434dc0a5SKonstantin Varlamov // function is defined for bad_function_call's vtable, its typeinfo and vtable
11434dc0a5SKonstantin Varlamov // will be defined as strong symbols in the library and weak symbols in other
12434dc0a5SKonstantin Varlamov // translation units. Only the strong symbol will be instrumented, increasing
13434dc0a5SKonstantin Varlamov // its size (due to the redzone) and leading to a serious ODR violation
14434dc0a5SKonstantin Varlamov // resulting in a crash.
15434dc0a5SKonstantin Varlamov // Some relevant bugs:
16434dc0a5SKonstantin Varlamov // https://github.com/google/sanitizers/issues/1017
17434dc0a5SKonstantin Varlamov // https://github.com/google/sanitizers/issues/619
18434dc0a5SKonstantin Varlamov // https://github.com/google/sanitizers/issues/398
19434dc0a5SKonstantin Varlamov // https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68016
20434dc0a5SKonstantin Varlamov // UNSUPPORTED: c++03, asan
21*3d405081SLouis Dionne
225a83710eSEric Fiselier // <functional>
235a83710eSEric Fiselier
245a83710eSEric Fiselier // template<CopyConstructible Fn, CopyConstructible... Types>
255a83710eSEric Fiselier // unspecified bind(Fn, Types...);
265a83710eSEric Fiselier // template<Returnable R, CopyConstructible Fn, CopyConstructible... Types>
275a83710eSEric Fiselier // unspecified bind(Fn, Types...);
285a83710eSEric Fiselier
293c62198cSLouis Dionne // https://llvm.org/PR16385
305a83710eSEric Fiselier
315a83710eSEric Fiselier #include <functional>
325a83710eSEric Fiselier #include <cmath>
335a83710eSEric Fiselier #include <cassert>
345a83710eSEric Fiselier
357fc6a556SMarshall Clow #include "test_macros.h"
367fc6a556SMarshall Clow
_pow(float a,float b)375a83710eSEric Fiselier float _pow(float a, float b)
385a83710eSEric Fiselier {
395a83710eSEric Fiselier return std::pow(a, b);
405a83710eSEric Fiselier }
415a83710eSEric Fiselier
main(int,char **)422df59c50SJF Bastien int main(int, char**)
435a83710eSEric Fiselier {
445a83710eSEric Fiselier std::function<float(float, float)> fnc = _pow;
455a83710eSEric Fiselier auto task = std::bind(fnc, 2.f, 4.f);
465a83710eSEric Fiselier auto task2(task);
475a83710eSEric Fiselier assert(task() == 16);
485a83710eSEric Fiselier assert(task2() == 16);
492df59c50SJF Bastien
502df59c50SJF Bastien return 0;
515a83710eSEric Fiselier }
52