Closed engun closed 10 months ago
Hi @engun , thanks for reporting this. I'm not using CLion, but I just made a change that I think may fix this. Can you try the latest version of the repo?
I just tried it. It's still the same. maybe more detailed information would help.
begin----------------------------------------------------------------------------------------------------------
In template: constexpr variable 'kFirst' must be initialized by a constant expression
error occurred here
in instantiation of static data member 'phmap::priv::memory_internal::OffsetOf<phmap::priv::memory_internal::IsLayoutCompatible<unsigned long long, unsigned int>::Pair>::kFirst' requested here
in instantiation of static data member 'phmap::priv::memory_internal::IsLayoutCompatible<unsigned long long, unsigned int>::value' requested here
in instantiation of function template specialization 'phmap::priv::map_slot_policy<unsigned long long, unsigned int>::transfer<std::allocator<std::pair<const unsigned long long, unsigned int>>>' requested here
in instantiation of function template specialization 'phmap::priv::FlatHashMapPolicy<unsigned long long, unsigned int>::transfer<std::allocator<std::pair<const unsigned long long, unsigned int>>>' requested here
in instantiation of function template specialization 'phmap::priv::hash_policy_traits<phmap::priv::FlatHashMapPolicy<unsigned long long, unsigned int>>::transfer_impl<std::allocator<std::pair<const unsigned long long, unsigned int>>, ph... (skipping 4 contexts in backtrace; use -ftemplate-backtrace-limit=0 to see all)
in instantiation of function template specialization 'phmap::priv::parallel_hash_set<4, phmap::priv::raw_hash_set, std::shared_mutex, phmap::priv::FlatHashMapPolicy<unsigned long long, unsigned int>, phmap::Hash<uint64_t>, phmap::EqualT...
in instantiation of function template specialization 'phmap::priv::parallel_hash_map<4, phmap::priv::raw_hash_set, std::shared_mutex, phmap::priv::FlatHashMapPolicy<unsigned long long, unsigned int>, phmap::Hash<uint64_t>, phmap::EqualT...
in instantiation of function template specialization 'phmap::priv::parallel_hash_map<4, phmap::priv::raw_hash_set, std::shared_mutex, phmap::priv::FlatHashMapPolicy<unsigned long long, unsigned int>, phmap::Hash<uint64_t>, phmap::EqualT...
in instantiation of function template specialization 'phmap::priv::parallel_hash_map<4, phmap::priv::raw_hash_set, std::shared_mutex, phmap::priv::FlatHashMapPolicy<unsigned long long, unsigned int>, phmap::Hash<uint64_t>, phmap::EqualT...
in instantiation of function template specialization 'phmap::priv::parallel_hash_map<4, phmap::priv::raw_hash_set, std::shared_mutex, phmap::priv::FlatHashMapPolicy<unsigned long long, unsigned int>, phmap::Hash<uint64_t>, phmap::EqualT...
:4387:39: note: cast that performs the conversions of a reinterpret_cast is not allowed in a constant expression
Declaration location: phmap.h
namespace phmap::priv
public:
template<K = key_type, P = Policy, K * = nullptr>
MappedReference<P> parallel_hash_map::operator[](key_arg<K> &&key)
end----------------------------------------------------------------------------------------------------------
What compiler are you using within CLion, on what operating system?
Hum, weird, I cannot reproduce the issue with Visual Studio 2022.
Do you have a custom version of the macro offsetof
in your code? Either that or you use an older compiler which provides a non constexpr
version of offsetof
.
Yes, VS doesn't show this error and, in fact, doesn't affect CLION compilation, but my OCD tells me to raise an issue. after a brief study, this error is from the Clang prompt.
This is a great open-source project. I encountered a little problem while using it.
The compilation tool is CLion, and I'm using C++17.
The compiler is showing an annoying error message:
"In template: constexpr variable 'kFirst' must be initialized by a constant expression."