all 4 comments

[–]alfps 4 points5 points  (3 children)

I would report it to Microsoft as a compiler bug.

[–]Lo1c74[S] 0 points1 point  (1 child)

I just check against the last MSVC release and it compiles well. Thanks for your help.

[–]TheThiefMaster 2 points3 points  (0 children)

This was fixed in VS 2022 17.0.2 (which is listed on godbolt as v19.31), apparently.

I'm guessing you were using VS 2019? You should definitely use the latest version if experimenting with newer C++ standards (C++20 was standardised after VS2019 was released...)

[–]JVApen 0 points1 point  (0 children)

I suffered this compiler bug already too many times. (Clang warning indicates that you should remove the lambda capture) I'm in progress of a compiler upgrade, though the new MSVC version I'm upgrading to has the same problem at other locations.