blob: 65b4f7145a9265e240102fcc18a3ce6f2ff71479 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
|
// PR c++/110358
// { dg-do compile { target c++20 } }
// { dg-options "-Wdangling-reference" }
template<bool B>
struct bool_constant {
static constexpr bool value = B;
constexpr operator bool() const { return value; }
};
using true_type = bool_constant<true>;
using false_type = bool_constant<false>;
struct S {
template<bool B>
[[gnu::no_dangling(B)]] int &foo (const int &);
};
void
g ()
{
[[maybe_unused]] const int &x0 = S().foo<false_type{}> (42); // { dg-warning "dangling" }
[[maybe_unused]] const int &x1 = S().foo<true_type{}> (42); // { dg-bogus "dangling" }
}
|