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 // UNSUPPORTED: c++03
10
11 // RUN: %{build} -O2
12 // RUN: %{run}
13
14 // <map>
15
16 // Previously this code caused a segfault when compiled at -O2 due to undefined
17 // behavior in __tree. See https://llvm.org/PR28469
18
19 #include <functional>
20 #include <map>
21
dummy()22 void dummy() {}
23
24 struct F {
25 std::map<int, std::function<void()> > m;
FF26 F() { m[42] = &dummy; }
27 };
28
main(int,char **)29 int main(int, char**) {
30 F f;
31 f = F();
32
33 return 0;
34 }
35