https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95200
--- Comment #2 from Jonathan Wakely <redi at gcc dot gnu.org> --- Although the actual cause of the behaviour you see is due to violating a different requirement. The explicit specialization hash<EnumType> is not declared in map_obj.h which means it gets implicitly instantiated using the default definition of std::hash for enumeration types. An explicit specialization needs to be declared before any use that would cause the implicit instantiation to happen.