Open spectre-ns opened 1 year ago
Example of failed build
https://github.com/spectre-ns/xtensor/actions/runs/6706077908/job/18221831529
I guess we need to capture needs_cast
here, but I wonder if it's a compiler issue. Do you have the same issue with MSVC 2022 ?
@JohanMabille yes the same issue exists in MSVC 2022
@JohanMabille looks like this is a bug as constexpr
variables should be captured in lambda scope implicitly.
Specifically MSVC:
Also there are issues out of the box around tbb defining min and max that need to be mitigated using #define NOMINMAX
@tdegeus this issue isn't C++20 specific. Not sure what that label means though.
@spectre-ns @JohanMabille hello, did you find a workaround for this problem? Activating the flag /Zc:lambda
does solve the failed capture of the constexpr var in the lambda https://learn.microsoft.com/en-us/cpp/build/reference/zc-lambda?view=msvc-170 . However the syntax error: 'template'
remains on this line (and several others):
Hi @PerretB I have not found a workaround. It works in clang and GCC so it is a compiler issue...
This small example triggers the error
#include <xtensor/xarray.hpp>
#include <xtensor/xrandom.hpp>
#include <xtensor-blas/xlinalg.hpp>
int main()
{
auto W1 = xt::random::rand<float>({10, 50}) - 0.5f;
auto X = xt::random::rand<float>({10, 50}) - 0.5f;
xt::xarray<float> d1 = xt::linalg::dot(W1, X);
return 0;
}
cmake_minimum_required(VERSION 3.14)
project(xt_tbb)
set(XTENSOR_USE_XSIMD 1)
set(XTENSOR_USE_TBB 1)
find_package(xtensor REQUIRED)
find_package(xtensor-blas REQUIRED)
add_executable(xt_tbb main.cpp)
target_compile_options(xt_tbb PUBLIC "/Zc:lambda")
target_include_directories(xt_tbb PUBLIC ${xtensor-blas_INCLUDE_DIRS})
target_link_libraries(xt_tbb PUBLIC xtensor)
C:\Program Files (x86)\xtensor\include\xtensor\xassign.hpp(1252,41): error C2187: syntax error: 'template' was unexpected here
Windows 10 MSVC 2019 Enterprise C++20
Fails to compile with both XSIMD and TBB enabled. Fails with the following
syntax error: 'template'
On line 1252 of xassign.hpp