Skip to content

Fix two compiler errors#1

Merged
SpriteOvO merged 2 commits intoSpriteOvO:devfrom
Chaoses-Ib:fix-compiler-errors
May 21, 2022
Merged

Fix two compiler errors#1
SpriteOvO merged 2 commits intoSpriteOvO:devfrom
Chaoses-Ib:fix-compiler-errors

Conversation

@Chaoses-Ib
Copy link
Copy Markdown
Contributor

@Chaoses-Ib Chaoses-Ib commented May 20, 2022

VS: 17.1.2
MSVC: 19.31.31105

Missing header <array>


(E2500 is a false positive error from the editor, it doesn't affect the compiler)

Fix:

#include <array>

Missing appropriate constructor for msvc_c7599_false_positive_workaround

1>C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.31.31103\include\xmemory(676,18): error C2672: 'std::construct_at': no matching overloaded function found
1>C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.31.31103\include\vector(602): message : see reference to function template instantiation 'void std::_Default_allocator_traits<_Alloc>::construct<_Ty,std::thread,std::span<const std::byte,18446744073709551615>>(_Alloc &,_Objty *const ,std::thread &&,std::span<const std::byte,18446744073709551615> &&)' being compiled
1>        with
1>        [
1>            _Alloc=std::allocator<sigmatch::multi_threaded_searcher::thread_info>,
1>            _Ty=sigmatch::multi_threaded_searcher::thread_info,
1>            _Objty=sigmatch::multi_threaded_searcher::thread_info
1>        ]
1>C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.31.31103\include\vector(607): message : see reference to function template instantiation 'void std::_Default_allocator_traits<_Alloc>::construct<_Ty,std::thread,std::span<const std::byte,18446744073709551615>>(_Alloc &,_Objty *const ,std::thread &&,std::span<const std::byte,18446744073709551615> &&)' being compiled
1>        with
1>        [
1>            _Alloc=std::allocator<sigmatch::multi_threaded_searcher::thread_info>,
1>            _Ty=sigmatch::multi_threaded_searcher::thread_info,
1>            _Objty=sigmatch::multi_threaded_searcher::thread_info
1>        ]
1>C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.31.31103\include\vector(620): message : see reference to function template instantiation '_Ty &std::vector<_Ty,std::allocator<_Ty>>::_Emplace_back_with_unused_capacity<std::thread,std::span<const std::byte,18446744073709551615>>(std::thread &&,std::span<const std::byte,18446744073709551615> &&)' being compiled
1>        with
1>        [
1>            _Ty=sigmatch::multi_threaded_searcher::thread_info
1>        ]
1>C:\sigmatch\include\sigmatch/sigmatch.hpp(2159): message : see reference to function template instantiation '_Ty &std::vector<_Ty,std::allocator<_Ty>>::emplace_back<std::thread,std::span<const std::byte,18446744073709551615>>(std::thread &&,std::span<const std::byte,18446744073709551615> &&)' being compiled
1>        with
1>        [
1>            _Ty=sigmatch::multi_threaded_searcher::thread_info
1>        ]
1>C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.31.31103\include\xmemory(676,18): error C2783: '_Ty *std::construct_at(_Ty *const ,_Types &&...) noexcept(<expr>)': could not deduce template argument for '<unnamed-symbol>'
1>C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.31.31103\include\xutility(134): message : see declaration of 'std::construct_at'
1>C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.31.31103\include\xmemory(680,47): error C2440: 'initializing': cannot convert from 'initializer list' to 'sigmatch::multi_threaded_searcher::thread_info'
1>C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.31.31103\include\xmemory(680,47): message : Invalid aggregate initialization

Test code:

1>C:\sigmatch\include\sigmatch/sigmatch.hpp(2165,1): error C2665: 'sigmatch::impl::msvc_c7599_false_positive_workaround::msvc_c7599_false_positive_workaround': none of the 3 overloads could convert all the argument types
1>C:\sigmatch\include\sigmatch/sigmatch.hpp(955,1): message : could be 'sigmatch::impl::msvc_c7599_false_positive_workaround::msvc_c7599_false_positive_workaround(sigmatch::impl::msvc_c7599_false_positive_workaround &&)'
1>C:\sigmatch\include\sigmatch/sigmatch.hpp(955,1): message : or       'sigmatch::impl::msvc_c7599_false_positive_workaround::msvc_c7599_false_positive_workaround(const sigmatch::impl::msvc_c7599_false_positive_workaround &)'
1>C:\sigmatch\include\sigmatch/sigmatch.hpp(955,1): message : or       'sigmatch::impl::msvc_c7599_false_positive_workaround::msvc_c7599_false_positive_workaround(void)'
1>C:\sigmatch\include\sigmatch/sigmatch.hpp(2165,1): message : or       'sigmatch::impl::msvc_c7599_false_positive_workaround::msvc_c7599_false_positive_workaround<const std::byte,18446744073709551615>(const std::span<const std::byte,18446744073709551615> &)', which inherits 'std::span<const std::byte,18446744073709551615>::span(const std::span<_OtherTy,_OtherExtent> &) noexcept' via base class 'std::span<const std::byte,18446744073709551615>'
1>C:\sigmatch\include\sigmatch/sigmatch.hpp(2165,1): message : while trying to match the argument list '(std::span<const std::byte,18446744073709551615>)'

I'm not sure whether this is a bug of MSVC, but there is no harm to add a constructor to fix it:

class msvc_c7599_false_positive_workaround : public std::span<const std::byte>
{
public:
    using std::span<const std::byte>::span;
    
    msvc_c7599_false_positive_workaround(const std::span<const std::byte>& span) : std::span<const std::byte>(span) {}
};

Copy link
Copy Markdown
Owner

@SpriteOvO SpriteOvO left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Thanks!

@SpriteOvO SpriteOvO merged commit 2ca983d into SpriteOvO:dev May 21, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants