[Bug 264877] clang-14 fails with unreasonable cryptic message on a valid C++ code

From: <bugzilla-noreply_at_freebsd.org>
Date: Fri, 24 Jun 2022 20:41:41 UTC
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=264877

Dimitry Andric <dim@FreeBSD.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |emaste@freebsd.org

--- Comment #2 from Dimitry Andric <dim@FreeBSD.org> ---
I'm inclined to say "you're holding it wrong" here, but this discussion should
really be taken upstream.

Previously, when only including <stdexcept>, you were just lucky that the swap
definition was pulled in transitively via <type_traits> (and that was also
completely by accident), and it seemed to sort-of work.

At some point upstream committed
https://github.com/llvm/llvm-project/commit/6adbc83ee9e46b476e0f75d5671c3a21f675a936:

commit 6adbc83ee9e46b476e0f75d5671c3a21f675a936
Author: Christopher Di Bella <cjdb@google.com>
Date:   Sat Jun 5 02:47:47 2021 +0000

    [libcxx][modularisation] moves <utility> content out of <type_traits>

    Moves:

    * `std::move`, `std::forward`, `std::declval`, and `std::swap` into
      `__utility/${FUNCTION_NAME}`.
    * `std::swap_ranges` and `std::iter_swap` into
      `__algorithm/${FUNCTION_NAME}`

    Differential Revision: https://reviews.llvm.org/D103734

This moved stuff that should really be in <utility>, such as swap() into more
modular headers, and it had the side effect of only leaving a partial swap
declaration in <type_traits> that is explicitly *not* exposed (via the
_LIBCPP_INLINE_VISIBILITY macro):

template <class _Tp>
inline _LIBCPP_INLINE_VISIBILITY
_LIBCPP_CONSTEXPR_AFTER_CXX17 __swap_result_t<_Tp>
swap(_Tp& __x, _Tp& __y) _NOEXCEPT_(is_nothrow_move_constructible<_Tp>::value
&&
                                    is_nothrow_move_assignable<_Tp>::value);

I am unsure why this declaration has been left in, though. If I simply comment
it out, the compile error for your test case at least becomes a lot clearer:

bug264877/test.cpp:9:7: error: no member named 'swap' in namespace 'std'
        std::swap(X1, X2);
        ~~~~~^

However, the decltype of swap() is used in a few macros after that, so
completely removing it might not be the best course of action.

-- 
You are receiving this mail because:
You are the assignee for the bug.