public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libstdc++/102894] New: make_any is not SFINAE-friendly
@ 2021-10-22  9:40 de34 at live dot cn
  2021-10-22 21:41 ` [Bug libstdc++/102894] " redi at gcc dot gnu.org
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: de34 at live dot cn @ 2021-10-22  9:40 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102894

            Bug ID: 102894
           Summary: make_any is not SFINAE-friendly
           Product: gcc
           Version: 12.0
            Status: UNCONFIRMED
          Keywords: accepts-invalid
          Severity: normal
          Priority: P3
         Component: libstdc++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: de34 at live dot cn
  Target Milestone: ---

std::make_any is specified in [any.nonmembers] p2-3 via "Effects: Equivalent
to: ...". According to [structure.specifications] p4, it propagates the
"Constraints:" of the constructor (in [any.cons] p11 and p17), and thus
SFINAE-friendly.

The following program should fail to compile. But currently it compiles with
libstdc++ due to lack of constraints. Note that std::make_optional is correctly
constrained in libstdc++.

Wandbox link:https://wandbox.org/permlink/noMWBjdCp0hg1pEZ

#include <type_traits>
#include <utility>
#include <any>

namespace test {
template<class T, class... Args>
auto test_make_any(int)
    -> decltype((void)std::make_any<T>(std::declval<Args>()...),
std::true_type{});
template<class, class...>
auto test_make_any(...) -> std::false_type;
template<class T, class... Args>
inline constexpr bool can_make_any = decltype(test_make_any<T,
Args...>(0))::value;
}

int main()
{
    static_assert(test::can_make_any<int, int, int>); // should not pass
}

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2021-11-26 16:48 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-22  9:40 [Bug libstdc++/102894] New: make_any is not SFINAE-friendly de34 at live dot cn
2021-10-22 21:41 ` [Bug libstdc++/102894] " redi at gcc dot gnu.org
2021-10-22 22:10 ` cvs-commit at gcc dot gnu.org
2021-10-22 22:11 ` redi at gcc dot gnu.org
2021-11-24 11:51 ` cvs-commit at gcc dot gnu.org
2021-11-26 16:35 ` cvs-commit at gcc dot gnu.org
2021-11-26 16:48 ` redi at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).