Skip to content

Commit 6e2f55a

Browse files
committed
Test causing an OOM
1 parent 047b136 commit 6e2f55a

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed

clang/test/Modules/pr83237.cppm

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
// RUN: rm -rf %t
2+
// RUN: mkdir -p %t
3+
// RUN: split-file %s %t
4+
//
5+
// RUN: %clang_cc1 -std=c++20 %t/type_traits.cppm -emit-module-interface -o %t/type_traits.pcm
6+
// RUN: %clang_cc1 -std=c++20 %t/test.cpp -fprebuilt-module-path=%t -verify
7+
8+
//--- type_traits.cppm
9+
export module type_traits;
10+
11+
export template <typename T>
12+
constexpr bool is_pod_v = __is_pod(T);
13+
14+
//--- test.cpp
15+
import type_traits;
16+
// Base is either void or wrapper<T>.
17+
template <class Base> struct wrapper : Base {};
18+
template <> struct wrapper<void> {};
19+
20+
// wrap<0>::type<T> is wrapper<T>, wrap<1>::type<T> is wrapper<wrapper<T>>,
21+
// and so on.
22+
template <int N>
23+
struct wrap {
24+
template <class Base>
25+
using type = wrapper<typename wrap<N-1>::template type<Base>>;
26+
};
27+
28+
template <>
29+
struct wrap<0> {
30+
template <class Base>
31+
using type = wrapper<Base>;
32+
};
33+
34+
inline constexpr int kMaxRank = 40;
35+
template <int N, class Base = void>
36+
using rank = typename wrap<N>::template type<Base>;
37+
using rank_selector_t = rank<40>;
38+
39+
static_assert(is_pod_v<rank_selector_t>, "Must be POD");

0 commit comments

Comments
 (0)