boostorg / hana

Your standard library for metaprogramming
http://boostorg.github.io/hana
Boost Software License 1.0
1.66k stars 217 forks source link

`hana::any_of()/if_()` example code fails on the latest MSVC #529

Closed Arech closed 2 months ago

Arech commented 2 months ago

Hey guys and gals, thank you for this awesome library!

I got a weird issue with hana::any_of() that I was even able to reproduce on godbolt: https://godbolt.org/z/6eaxaahYj

In short, even example code of hana::any_of() as described in the docs: https://www.boost.org/doc/libs/1_84_0/libs/hana/doc/html/group__group-_searchable.html#ga5f7ff0125c448983e1b96c3ffb84f646 fails on the latest MSVC, but compiles nice on (not so latest) gcc & clang.

I've encountered that using boost v1.84 from vcpkg baseline 898b728edc5e0d12b50015f9cd18247c4257a3eb, but I assume godbolt uses different baseline and maybe even version, and nonetheless it fails there too with exactly the same diagnosis:

boost/hana/eval_if.hpp(60): error C2446: ':': no conversion from 'const boost::hana::integral_constant<bool,false>' to 'const boost::hana::integral_constant<bool,true>'
boost/hana/eval_if.hpp(60): note: No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called
....

I tried /Zc:__cplusplus suggestion, but no luck...

My MSVC Version 17.9.6. cl.exe version

Microsoft (R) C/C++ Optimizing Compiler Version 19.39.33523 for x64

I'll very much appreciate suggestions how to fix that. I didn't expect such issue, honestly...

Arech commented 2 months ago

Same for hana::if_():

Arech commented 2 months ago

eval_if() example works though: https://godbolt.org/z/rWvdvjPKv

Arech commented 2 months ago

I posted this as a potential bug in MSVC bug tracker and just got a reply from their compiler team, that it compiles with /Zc:ternary and indeed, it at least compiles: https://godbolt.org/z/sWeG3s3nv

I guess this concludes the ticket, so I'm closing it. Hana is so good that I expected it to be more lively supported :D