// PR c++/110358 // { dg-do compile { target c++20 } } // { dg-options "-Wdangling-reference" } template constexpr bool is_reference_v = false; template constexpr bool is_reference_v = true; template constexpr bool is_reference_v = true; template struct [[gnu::no_dangling(is_reference_v)]] S { int i; int &foo (const int &); }; template struct X { template struct [[gnu::no_dangling(is_reference_v && is_reference_v)]] Y { int i; int &foo (const int &); }; }; void g () { [[maybe_unused]] const int &x0 = S().foo (42); // { dg-bogus "dangling" } [[maybe_unused]] const int &x1 = S().foo (42); // { dg-warning "dangling" } [[maybe_unused]] const auto &x2 = X::Y<>().foo (42); // { dg-warning "dangling" } [[maybe_unused]] const auto &x3 = X::Y<>().foo (42); // { dg-bogus "dangling" } }