xtensor icon indicating copy to clipboard operation
xtensor copied to clipboard

[Bug] Fails to compile with TBB and XSIMD enabled

Open spectre-ns opened this issue 2 years ago • 9 comments

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

spectre-ns avatar Oct 31 '23 11:10 spectre-ns

Example of failed build

https://github.com/spectre-ns/xtensor/actions/runs/6706077908/job/18221831529

spectre-ns avatar Oct 31 '23 12:10 spectre-ns

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 avatar Nov 01 '23 07:11 JohanMabille

@JohanMabille yes the same issue exists in MSVC 2022

spectre-ns avatar Nov 01 '23 08:11 spectre-ns

@JohanMabille looks like this is a bug as constexpr variables should be captured in lambda scope implicitly.

https://stackoverflow.com/questions/33873788/can-i-use-a-constexpr-value-in-a-lambda-without-capturing-it

Specifically MSVC:

https://stackoverflow.com/questions/71493298/why-cant-a-constexpr-variable-be-seen-only-by-a-capturing-lambda

spectre-ns avatar Nov 01 '23 10:11 spectre-ns

Also there are issues out of the box around tbb defining min and max that need to be mitigated using #define NOMINMAX

spectre-ns avatar Nov 01 '23 11:11 spectre-ns

@tdegeus this issue isn't C++20 specific. Not sure what that label means though.

spectre-ns avatar Nov 12 '23 11:11 spectre-ns

@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):

https://github.com/xtensor-stack/xtensor/blob/8c0a484f04eccd0dbc0e25eb58a97de000fb048b/include/xtensor/xassign.hpp#L1252

PerretB avatar Jul 19 '24 10:07 PerretB

Hi @PerretB I have not found a workaround. It works in clang and GCC so it is a compiler issue...

spectre-ns avatar Jul 19 '24 11:07 spectre-ns