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
22void dummy() {}
23
24struct F {
25 std::map<int, std::function<void()> > m;
26 F() { m[42] = &dummy; }
27};
28
29int main(int, char**) {
30 F f;
31 f = F();
32
33 return 0;
34}
35

source code of libcxx/test/std/containers/associative/map/PR28469_undefined_behavior_segfault.sh.cpp