Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mixing #include <memory> and import std.core; emits error C2668: 'std::_Atomic_wait_direct': ambiguous call to overloaded function #1384

Closed
mediabuff opened this issue Oct 20, 2020 · 11 comments
Labels
external This issue is unrelated to the STL

Comments

@mediabuff
Copy link

mediabuff commented Oct 20, 2020

1>C:\Program Files (x86)\Microsoft Visual Studio\2019\Preview\VC\Tools\MSVC\14.28.29331\include\atomic(971,1): error C2668: 'std::_Atomic_wait_direct': ambiguous call to overloaded function

1>d:\agent_work\3\s\binaries\x86ret\inc\atomic(394,6): message : could be 'void std::_Atomic_wait_direct<_Ty,_Integral>(const std::_Atomic_storage<_Ty,4> *const ,_Value_type,const std::memory_order) noexcept' [found using argument-dependent lookup]
1> with
1> [
1> _Ty=long,
1> _Integral=long,
1> _Value_type=long
1> ]
1>C:\Program Files (x86)\Microsoft Visual Studio\2019\Preview\VC\Tools\MSVC\14.28.29331\include\atomic(394,6): message : or 'void std::_Atomic_wait_direct<_Ty,_Integral>(const std::_Atomic_storage<_Ty,4> *const ,_Value_type,const std::memory_order) noexcept'
1> with
1> [
1> _Ty=long,
1> _Integral=long,
1> _Value_type=long
1> ]
1>C:\Program Files (x86)\Microsoft Visual Studio\2019\Preview\VC\Tools\MSVC\14.28.29331\include\atomic(971,1): message : while trying to match the argument list '(const std::_Atomic_storage<_Ty,4> *, _Integral, const std::memory_order)'
1> with
1> [
1> _Ty=long
1> ]
1> and
1> [
1> _Integral=long
1> ]
1>C:\Program Files (x86)\Microsoft Visual Studio\2019\Preview\VC\Tools\MSVC\14.28.29331\include\atomic(970): message : while compiling class template member function 'void std::_Atomic_storage<_Ty,4>::wait(const long,const std::memory_order) noexcept const'
1> with
1> [
1> _Ty=long
1> ]
1>C:\Program Files (x86)\Microsoft Visual Studio\2019\Preview\VC\Tools\MSVC\14.28.29331\include\atomic(2855): message : see reference to function template instantiation 'void std::_Atomic_storage<_Ty,4>::wait(const long,const std::memory_order) noexcept const' being compiled
1> with
1> [
1> _Ty=long
1> ]
1>C:\Program Files (x86)\Microsoft Visual Studio\2019\Preview\VC\Tools\MSVC\14.28.29331\include\atomic(1444): message : see reference to class template instantiation 'std::_Atomic_storage<_Ty,4>' being compiled
1> with
1> [
1> _Ty=long
1> ]
1>C:\Program Files (x86)\Microsoft Visual Studio\2019\Preview\VC\Tools\MSVC\14.28.29331\include\atomic(1647): message : see reference to class template instantiation 'std::_Atomic_integral<_Ty,4>' being compiled
1> with
1> [
1> _Ty=long
1> ]
1>C:\Program Files (x86)\Microsoft Visual Studio\2019\Preview\VC\Tools\MSVC\14.28.29331\include\atomic(2143): message : see reference to class template instantiation 'std::_Atomic_integral_facade<_Ty>' being compiled
1> with
1> [
1> _Ty=long
1> ]
1>C:\Program Files (x86)\Microsoft Visual Studio\2019\Preview\VC\Tools\MSVC\14.28.29331\include\atomic(2880): message : see reference to class template instantiation 'std::atomic' being compiled

@fsb4000
Copy link
Contributor

fsb4000 commented Oct 20, 2020

Could you also provide code sample, not only error messages?

@mediabuff
Copy link
Author

Please use the zipped project in
mediabuff/WinDx.IPC#1

Compile project WinDx.IPC.Alpc

@fsb4000
Copy link
Contributor

fsb4000 commented Oct 20, 2020

Thank you! I reduced your sample code to this:

C:\Dev\STL\playground\repro>type main.cpp
#include <memory> // from #include "alpc_message.hpp"

import std.core;

int main()
{}
C:\Dev\STL\playground\repro>cl /std:c++latest  /experimental:module /EHsc /MD /W4   main.cpp
Оптимизирующий компилятор Microsoft (R) C/C++ версии 19.28.29331 для x64
(C) Корпорация Майкрософт (Microsoft Corporation).  Все права защищены.

/std:c++latest предоставляется как предварительная версия языковых функций из последнего
рабочего черновика C++. Мы приветствуем сообщения об ошибках и предложения к улучшению.
Однако обратите внимание, что эти функции предоставляются как есть, без поддержки и могут
измениться или быть удалены по мере развития рабочего черновика. Дополнительные сведения:
https://go.microsoft.com/fwlink/?linkid=2045807.

Экспериментальные функции предоставляются в качестве предварительной версии предложенных языковых функций,
и мы будем рады получить от вас отзывы об ошибках и предложения по улучшению. Тем не менее
обратите внимание, что эти экспериментальные функции являются нестандартными и предоставляются "как есть", без
поддержки, а также могут быть изменены или удалены без уведомления. Сведения см. по адресу
http://go.microsoft.com/fwlink/?LinkID=691081.

main.cpp
C:\Program Files (x86)\Microsoft Visual Studio\2019\Preview\VC\Tools\MSVC\14.28.29331\include\atomic(971): error C2668: std::_Atomic_wait_direct: неоднозначный вызов перегруженной функции
d:\agent\_work\3\s\binaries\x86ret\inc\atomic(394): note: может быть "void std::_Atomic_wait_direct<_Ty,_Integral>(const std::_Atomic_storage<_Ty,4> *const ,_Value_type,const std::memory_order) noexcept" [найдено при поиске с зависимостью от аргументов]
        with
        [
            _Ty=long,
            _Integral=long,
            _Value_type=long
        ]
C:\Program Files (x86)\Microsoft Visual Studio\2019\Preview\VC\Tools\MSVC\14.28.29331\include\atomic(394): note: или       "void std::_Atomic_wait_direct<_Ty,_Integral>(const std::_Atomic_storage<_Ty,4> *const ,_Value_type,const std::memory_order) noexcept"
        with
        [
            _Ty=long,
            _Integral=long,
            _Value_type=long
        ]
C:\Program Files (x86)\Microsoft Visual Studio\2019\Preview\VC\Tools\MSVC\14.28.29331\include\atomic(971): note: при попытке сопоставить список аргументов "(const std::_Atomic_storage<_Ty,4> *, _Integral, const std::memory_order)"
        with
        [
            _Ty=long
        ]
        and
        [
            _Integral=long
        ]
C:\Program Files (x86)\Microsoft Visual Studio\2019\Preview\VC\Tools\MSVC\14.28.29331\include\atomic(970): note: во время компиляции функции-члена класс шаблон "void std::_Atomic_storage<_Ty,4>::wait(const long,const std::memory_order) noexcept const"
        with
        [
            _Ty=long
        ]
C:\Program Files (x86)\Microsoft Visual Studio\2019\Preview\VC\Tools\MSVC\14.28.29331\include\atomic(2855): note: выполняется компиляция ссылки на экземпляр шаблон функции "void std::_Atomic_storage<_Ty,4>::wait(const long,const std::memory_order) noexcept const"
        with
        [
            _Ty=long
        ]
C:\Program Files (x86)\Microsoft Visual Studio\2019\Preview\VC\Tools\MSVC\14.28.29331\include\atomic(1444): note: выполняется компиляция ссылки на экземпляр класс шаблон функции "std::_Atomic_storage<_Ty,4>"
        with
        [
            _Ty=long
        ]
C:\Program Files (x86)\Microsoft Visual Studio\2019\Preview\VC\Tools\MSVC\14.28.29331\include\atomic(1647): note: выполняется компиляция ссылки на экземпляр класс шаблон функции "std::_Atomic_integral<_Ty,4>"
        with
        [
            _Ty=long
        ]
C:\Program Files (x86)\Microsoft Visual Studio\2019\Preview\VC\Tools\MSVC\14.28.29331\include\atomic(2143): note: выполняется компиляция ссылки на экземпляр класс шаблон функции "std::_Atomic_integral_facade<_Ty>"
        with
        [
            _Ty=long
        ]
C:\Program Files (x86)\Microsoft Visual Studio\2019\Preview\VC\Tools\MSVC\14.28.29331\include\atomic(2880): note: выполняется компиляция ссылки на экземпляр класс шаблон функции "std::atomic<long>"

C:\Dev\STL\playground\repro>

STL version

Microsoft Visual Studio Community 2019 Preview
Version 16.8.0 Preview 4.0

@mediabuff
Copy link
Author

any work around so that I can progress ?

@CaseyCarter
Copy link
Member

@mediabuff I'm not yet a modules expert - @StephanTLavavej has touched modules, which makes him the closest thing we have to an expert - but I strongly suspect that defining things both in a module and in the global fragment (by including the headers) violates the One Definition Rule. If that's the case, your avenues forward are to either avoid including headers covered by a module imported into the same translation unit, or to avoid using our non-standard library modules and just include headers.

@CaseyCarter CaseyCarter added the question Further information is requested label Oct 20, 2020
@StephanTLavavej
Copy link
Member

@cdacamar should know whether this is supported. My understanding is also that you shouldn't mix the experimental STL modules and the classic STL headers - you should use one or the other.

@StephanTLavavej StephanTLavavej changed the title Version 16.8.0 Preview 4.0 - atomic(971,1): error C2668: 'std::_Atomic_wait_direct': ambiguous call to overloaded function Mixing #include <memory> and import std.core; emits error C2668: 'std::_Atomic_wait_direct': ambiguous call to overloaded function Oct 20, 2020
@mediabuff
Copy link
Author

thank you all. But a pratical/transition question though if you can't mix STL modules and STL headers. If I am an author of c++ module - that uses third-party headers - which may include STL headers - what is the transiton path ?

@cdacamar
Copy link
Contributor

@StephanTLavavej this scenario should work. Specifically the guidance w.r.t. using modules + textual inclusion is:

// #include directives
// import directives
// user source

So textual inclusion must always be before module import directives. The initial error observed looks very much like a compiler bug to me.

@mediabuff
Copy link
Author

Exactly how I had laid out. Agree, seems like a compiler bug. How do to get to VC++ team

@CaseyCarter
Copy link
Member

this scenario should work.

I stand corrected - thanks, @cdacamar!

Agree, seems like a compiler bug. How do to get to VC++ team

Please head over to "Report a Problem" at Developer Community and file a bug report, ideally with @fsb4000's minimized repro.

@CaseyCarter CaseyCarter added external This issue is unrelated to the STL and removed question Further information is requested labels Oct 21, 2020
@samrrr
Copy link

samrrr commented Jun 1, 2022

This bug still exist.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
external This issue is unrelated to the STL
Projects
None yet
Development

No branches or pull requests

6 participants