MSVC 19.x is not working
Nobody has claimed this yet.
- Dominant language
- C++
- Stars
- 507
- Forks
- 87
- Avg merge
- 15h 27m
- Merged PRs (30d)
- 2
Description
The mdspan library doesn't compile when using it in Visual Studio 2022 and MSVC 19.35.
With the following cMake and example source results in a compilation error:
CMakeLists.txt.
cmake_minimum_required(VERSION 3.13 FATAL_ERROR)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED Yes)
project(mdspanTest
VERSION 0.0.1
)
set(MDSPAN_CXX_STANDARD ${CMAKE_CXX_STANDARD} CACHE INTERNAL "Use CMAKE_CXX_STANDARD .")
include(FetchContent)
FetchContent_Declare(mdspan
GIT_REPOSITORY https://github.com/kokkos/mdspan.git
GIT_TAG mdspan-0.6.0
)
FetchContent_GetProperties(mdspan)
if(NOT mdspan_POPULATED)
FetchContent_Populate(mdspan)
add_subdirectory(${mdspan_SOURCE_DIR} ${mdspan_BINARY_DIR} EXCLUDE_FROM_ALL)
endif()
add_executable(${PROJECT_NAME}
main.cpp
)
target_link_libraries(${PROJECT_NAME}
std::mdspan
)
main.cpp
#include <cstddef>
#include <iostream>
#include <experimental/mdspan>
#include <vector>
int main()
{
std::vector v{ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 };
auto ms2 = std::experimental::mdspan(v.data(), 2, 6);
}
Error
[1/2] Building CXX object CMakeFiles\mdspanTest.dir\main.cpp.obj
FAILED: CMakeFiles/mdspanTest.dir/main.cpp.obj
C:\PROGRA~1\MIB055~1\2022\COMMUN~1\VC\Tools\MSVC\1435~1.322\bin\Hostx64\x64\cl.exe /nologo /TP -IC:\Projects\Mdspan_Test\out\build\x64-Debug\_deps\mdspan-src\include /DWIN32 /D_WINDOWS /W3 /GR /EHsc /MDd /Zi /Ob0 /Od /RTC1 -std:c++17 /showIncludes /FoCMakeFiles\mdspanTest.dir\main.cpp.obj /FdCMakeFiles\mdspanTest.dir\ /FS -c C:\Projects\Mdspan_Test\main.cpp
C:\Projects\Mdspan_Test\out\build\x64-Debug\_deps\mdspan-src\include\experimental\__p0009_bits\layout_stride.hpp(375): warning C4346: 'Extents::rank': dependent name is not a type
C:\Projects\Mdspan_Test\out\build\x64-Debug\_deps\mdspan-src\include\experimental\__p0009_bits\layout_stride.hpp(375): note: prefix with 'typename' to indicate a type
C:\Projects\Mdspan_Test\out\build\x64-Debug\_deps\mdspan-src\include\experimental\__p0009_bits\layout_stride.hpp(475): note: see reference to class template instantiation 'std::experimental::layout_stride::mapping<Extents>' being compiled
C:\Projects\Mdspan_Test\out\build\x64-Debug\_deps\mdspan-src\include\experimental\__p0009_bits\layout_stride.hpp(375): error C2059: syntax error: '...'
C:\Projects\Mdspan_Test\out\build\x64-Debug\_deps\mdspan-src\include\experimental\__p0009_bits\layout_stride.hpp(382): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
C:\Projects\Mdspan_Test\out\build\x64-Debug\_deps\mdspan-src\include\experimental\__p0009_bits\layout_stride.hpp(382): error C2062: type 'unknown-type' unexpected
C:\Projects\Mdspan_Test\out\build\x64-Debug\_deps\mdspan-src\include\experimental\__p0009_bits\layout_stride.hpp(384): error C2334: unexpected token(s) preceding '{'; skipping apparent function body
C:\Projects\Mdspan_Test\out\build\x64-Debug\_deps\mdspan-src\include\experimental\__p0009_bits\layout_stride.hpp(395): error C2270: 'is_exhaustive': modifiers not allowed on nonmember functions
C:\Projects\Mdspan_Test\out\build\x64-Debug\_deps\mdspan-src\include\experimental\__p0009_bits\layout_stride.hpp(406): error C2270: 'stride': modifiers not allowed on nonmember functions
C:\Projects\Mdspan_Test\out\build\x64-Debug\_deps\mdspan-src\include\experimental\__p0009_bits\layout_right.hpp(159): warning C4346: 'std::experimental::layout_right::mapping<Extents>::std::experimental::layout_right::mapping<Extents>::extents_type::rank': dependent name is not a type
C:\Projects\Mdspan_Test\out\build\x64-Debug\_deps\mdspan-src\include\experimental\__p0009_bits\layout_right.hpp(159): note: prefix with 'typename' to indicate a type
C:\Projects\Mdspan_Test\out\build\x64-Debug\_deps\mdspan-src\include\experimental\__p0009_bits\layout_right.hpp(220): note: see reference to class template instantiation 'std::experimental::layout_right::mapping<Extents>' being compiled
C:\Projects\Mdspan_Test\out\build\x64-Debug\_deps\mdspan-src\include\experimental\__p0009_bits\layout_right.hpp(159): error C2059: syntax error: '...'
C:\Projects\Mdspan_Test\out\build\x64-Debug\_deps\mdspan-src\include\experimental\__p0009_bits\layout_right.hpp(168): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
C:\Projects\Mdspan_Test\out\build\x64-Debug\_deps\mdspan-src\include\experimental\__p0009_bits\layout_right.hpp(168): error C2062: type 'unknown-type' unexpected
C:\Projects\Mdspan_Test\out\build\x64-Debug\_deps\mdspan-src\include\experimental\__p0009_bits\layout_right.hpp(170): error C2334: unexpected token(s) preceding '{'; skipping apparent function body
C:\Projects\Mdspan_Test\out\build\x64-Debug\_deps\mdspan-src\include\experimental\__p0009_bits\layout_right.hpp(177): error C2270: 'is_unique': modifiers not allowed on nonmember functions
C:\Projects\Mdspan_Test\out\build\x64-Debug\_deps\mdspan-src\include\experimental\__p0009_bits\layout_right.hpp(178): error C2270: 'is_exhaustive': modifiers not allowed on nonmember functions
C:\Projects\Mdspan_Test\out\build\x64-Debug\_deps\mdspan-src\include\experimental\__p0009_bits\layout_right.hpp(179): error C2270: 'is_strided': modifiers not allowed on nonmember functions
C:\Projects\Mdspan_Test\out\build\x64-Debug\_deps\mdspan-src\include\experimental\__p0009_bits\layout_right.hpp(186): error C2270: 'stride': modifiers not allowed on nonmember functions
C:\Projects\Mdspan_Test\out\build\x64-Debug\_deps\mdspan-src\include\experimental\__p0009_bits\mdspan.hpp(110): error C2059: syntax error: '...'
C:\Projects\Mdspan_Test\out\build\x64-Debug\_deps\mdspan-src\include\experimental\__p0009_bits/mdspan.hpp(372): note: see reference to class template instantiation 'std::experimental::mdspan<ElementType,Extents,LayoutPolicy,AccessorPolicy>' being compiled
C:\Projects\Mdspan_Test\out\build\x64-Debug\_deps\mdspan-src\include\experimental\__p0009_bits\mdspan.hpp(119): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
C:\Projects\Mdspan_Test\out\build\x64-Debug\_deps\mdspan-src\include\experimental\__p0009_bits\mdspan.hpp(119): error C2062: type 'unknown-type' unexpected
C:\Projects\Mdspan_Test\out\build\x64-Debug\_deps\mdspan-src\include\experimental\__p0009_bits\mdspan.hpp(123): error C2334: unexpected token(s) preceding ':'; skipping apparent function body
C:\Projects\Mdspan_Test\out\build\x64-Debug\_deps\mdspan-src\include\experimental\__p0009_bits\mdspan.hpp(26): fatal error C1075: '{': no matching token found
ninja: build stopped: subcommand failed.
Or here in the online demo: https://godbolt.org/z/W9bhGxzqf
Any idea where the error is from? And how it can be fixed?
Thanks,
Silvan
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the failure with the provided CMakeLists.txt and main.cpp using Visual Studio 2022 with MSVC 19.35. Start with include/experimental/__p0009_bits/layout_stride.hpp, layout_right.hpp, and mdspan.hpp, then compare the compiler diagnostics with the Godbolt example. Done means the example compiles successfully with the reported MSVC version.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cmake, cpp
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100