简体   繁体   中英

Why do I get "error: reference to 'align_val_t' is ambiguous" with Intel's C++ 2022 compiler when using std::inplace_merge?

When I try to compile this with the Intel C++ Compiler 2022 toolset for Visual Studio 2022:

#include <algorithm>

int main()
{
    int x = 0;
    std::inplace_merge(&x, &x, &x);
}

I get:

VC\Tools\MSVC\14.34.31933\include\xmemory(1429,48): error : reference to 'align_val_t' is ambiguous
                _Pbuf = ::operator new (_Size, align_val_t{alignof(_Ty)}, nothrow);
                                               ^
VC\Tools\MSVC\14.34.31933\include\algorithm(7152,57): note: in instantiation of function template specialization 'std::_Optimistic_temporary_buffer<int>::_Optimistic_temporary_buffer<long long>' requested here
    _Optimistic_temporary_buffer<_Iter_value_t<_BidIt>> _Temp_buf{(_STD min)(_Count1, _Count2)};
                                                        ^
VC\Tools\MSVC\14.34.31933\include\algorithm(7160,10): note: in instantiation of function template specialization 'std::inplace_merge<int *, std::less<>>' requested here
    _STD inplace_merge(_First, _Mid, _Last, less<>{});
         ^
Temp.cpp(6,7): note: in instantiation of function template specialization 'std::inplace_merge<int *>' requested here
        std::inplace_merge(&x, &x, &x);
             ^
VC\14.34.31933\include\vcruntime_new.h(27,16): note: candidate found by name lookup is 'std::align_val_t'
    enum class align_val_t : size_t {};
               ^
note: candidate found by name lookup is 'std::align_val_t'

I tried digging through the STL sources, but I can't find where the ambiguity is.

Why does this error occur? And how do I get around it?

Answering my own question, but it seems to be a bug with precompiled headers . This occurs even if the precompiled header files are empty.

Avoiding precompiled headers seems to avoid the issue.

If anyone has a better workaround or more details, please do post it.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM