Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mp_map_find seems not working properly using g++ #72

Open
HanatoK opened this issue Mar 10, 2022 · 4 comments
Open

mp_map_find seems not working properly using g++ #72

HanatoK opened this issue Mar 10, 2022 · 4 comments

Comments

@HanatoK
Copy link

HanatoK commented Mar 10, 2022

The code is at https://godbolt.org/z/KvjecnTe3. The code can be compiled if switching to clang 13.0.1, but gcc 11.2 or the trunk version fails. Interestingly, if I comment out line 22 and 23 as

 // boost::mp11::mp_list<enum_<Foo::A1>, int>,
 // boost::mp11::mp_list<enum_<Foo::A2>, double>,

then gcc can successfully compile the code. Any ideas?

@pdimov
Copy link
Member

pdimov commented Mar 10, 2022

Looks like a GCC bug. I'll try to figure out why it happens. Here's a workaround:

template <auto EnumVal> using enum_ = std::integral_constant<decltype(EnumVal), EnumVal>;

@pdimov
Copy link
Member

pdimov commented Mar 10, 2022

Interestingly, if I comment out line 22 and 23 as

Commenting out line 22 (Foo::A1) is enough. It looks like GCC doesn't take into account the type of EnumVal, just its value (which is 0 for both A1 and B1).

@HanatoK
Copy link
Author

HanatoK commented Mar 10, 2022

Thanks! this works for me. Just for your information, I tried similar code by using boost::mpl and it works (https://godbolt.org/z/zeGdoa3Te) for both gcc and clang.

Looks like a GCC bug. I'll try to figure out why it happens. Here's a workaround:

template <auto EnumVal> using enum_ = std::integral_constant<decltype(EnumVal), EnumVal>;

@pdimov
Copy link
Member

pdimov commented Mar 10, 2022

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants