too long lines were shrinked: /usr/lib/gcc/x86_64-pc-linux-gnu/15/include/g++-v15/bits/unordered_map.h:112:18: required from class std::unordered_map<std::pair<const antlr4::atn::PredictionContext*, const antlr4::atn::PredictionContext*>, std::unique_ptr<antlr4::atn::PredictionContextMergeCache::Entry>, std::hash<std::pair<con 112 | _Hashtable _M_h; | ^~~~ /var/tmp/portage/dev-cpp/antlr-cpp-4.11.1/work/runtime/src/atn/PredictionContextMergeCache.h:88:85: required from here 88 | PredictionContextHasher, PredictionContextComparer>; | ^ /usr/lib/gcc/x86_64-pc-linux-gnu/15/include/g++-v15/bits/hashtable.h:213:51: error: static assertion failed: hash function must be copy constructible 213 | static_assert(is_copy_constructible<_Hash>::value, | ^~~~~ ------------------------------------------------------------------- This is an unstable amd64 chroot image at a tinderbox (==build bot) name: 23.0_desktop-20240620-193015 UNMASKED: <sys-devel/gcc-15.0.9999:15 Please re-assign to toolchain@ if you get a test failure in C, C++, or Fortran code which makes no sense. ~dev-libs/icu-75.1 ~dev-libs/icu-layoutex-75.1 ~dev-lang/perl-5.40.0 ~virtual/perl-Archive-Tar-3.20.10_rc ~virtual/perl-CPAN-Meta-Requirements-2.143.0 ~virtual/perl-Compress-Raw-Bzip2-2.212.0 ~virtual/perl-DB_File-1.859.0 ~virtual/perl-Data-Dumper-2.189.0 ~virtual/perl-Devel-PPPort-3.720.0 ~virtual/perl-Exporter-5.780.0 ~virtual/perl-ExtUtils-CBuilder-0.280.240 ~virtual/perl-ExtUtils-Manifest-1.750.0 ~virtual/perl-File-Spec-3.900.0 ~virtual/perl-HTTP-Tiny-0.88.0 ~virtual/perl-IO-1.550.0 ~virtual/perl-IO-Compress-2.212.0 ~virtual/perl-IO-Socket-IP-0.420.0 ~virtual/perl-IO-Zlib-1.150.0 ~virtual/perl-Math-BigInt-2.3.2 ~virtual/perl-Math-BigInt-FastCalc-0.501.800 ~virtual/perl-Math-BigRat-2.3.2 ~virtual/perl-Module-CoreList-5.202.406.90 ~virtual/perl-Module-Metadata-1.0.38 ~virtual/perl-Pod-Simple-3.450.0 ~virtual/perl-Safe-2.460.0 ~virtual/perl-Socket-2.38.0 ~virtual/perl-Test-Harness-3.480.0 ~virtual/perl-Test-Simple-1.302.199 ~virtual/perl-Text-Tabs+Wrap-2024.1.0 ~virtual/perl-Time-HiRes-1.977.700 ~virtual/perl-Time-Local-1.350.0 ~virtual/perl-autodie-2.370.0 ~virtual/perl-bignum-0.670.0 ~virtual/perl-podlators-5.10.200_rc ~virtual/perl-threads-2.400.0 ~virtual/perl-threads-shared-1.690.0 ~virtual/perl-version-0.993.0 The attached etc.portage.tar.xz has all details. ------------------------------------------------------------------- gcc-config -l: [1] x86_64-pc-linux-gnu-15 * clang/llvm (if any): clang version 18.1.7 Target: x86_64-pc-linux-gnu Thread model: posix InstalledDir: /usr/lib/llvm/18/bin Configuration file: /etc/clang/x86_64-pc-linux-gnu-clang.cfg /usr/lib/llvm/18 18.1.7 Python 3.12.4 Available Ruby profiles: [1] ruby31 (with Rubygems) [2] ruby32 (with Rubygems) [3] ruby33 (with Rubygems) * Available Rust versions: [1] rust-bin-1.78.0 * The following VMs are available for generation-2: 1) Eclipse Temurin JDK 17.0.11_p9 [openjdk-bin-17] *) Eclipse Temurin JDK 21.0.3_p9 [openjdk-bin-21] 3) Eclipse Temurin JDK 8.412_p08 [openjdk-bin-8] Available Java Virtual Machines: [1] openjdk-bin-8 [2] openjdk-bin-17 [3] openjdk-bin-21 system-vm The Glorious Glasgow Haskell Compilation System, version 9.2.8 php cli (if any): go version go1.22.4 linux/amd64 HEAD of ::gentoo commit 8584f8fd3a9e8221d043baf2844a2d4744cdc6f6 Author: Repository mirror & CI <repomirrorci@gentoo.org> Date: Sat Jun 22 00:04:04 2024 +0000 2024-06-22 00:04:03 UTC emerge -qpvO dev-cpp/antlr-cpp [ebuild N ] dev-cpp/antlr-cpp-4.11.1 USE="-test"
Created attachment 896241 [details] emerge-info.txt
Created attachment 896242 [details] dev-cpp:antlr-cpp-4.11.1:20240622-012150.log
Created attachment 896243 [details] emerge-history.txt
Created attachment 896244 [details] environment
Created attachment 896245 [details] etc.clang.tar.xz
Created attachment 896246 [details] etc.portage.tar.xz
Created attachment 896247 [details] qlist-info.txt
Created attachment 896248 [details] temp.tar.xz
Introduced by https://gcc.gnu.org/git/?p=gcc.git;a=commitdiff;h=cc38bdf093c44918edff819ae6c73d03c726b341. Seems like it's a feature (rejecting bad code)?
I asked jwakely about this and he gave some advice. The new static_assert is intended to diagnose cases where the std::hash specialization is not complete at the point where the std::unordered_map is instantiated, because that's undefined behaviour. To fix it, make sure the std::hash<std::pair<const antlr4::atn::PredictionContext*, const antlr4::atn::PredictionContext*>> specialization is defined before trying to use it.
PredictionContext looks like a mess: https://github.com/antlr/antlr4/pull/2166.
I think this error should go away with https://github.com/antlr/antlr4/commit/9d7741d3fb1e0befe1ca32502a42a2809741053c which is in antlr-cpp-4.12.0
Here's a minimal reproducer that fails with GCC trunk, unless you use -DFIX #include <unordered_map> template <typename Key, typename Value, #ifdef FIX typename Hash = std::hash<Key>, typename Equal = std::equal_to<Key>, typename Allocator = std::allocator<std::pair<const Key, Value>>> #else typename Hash = typename std::unordered_map<Key, Value>::hasher, typename Equal = typename std::unordered_map<Key, Value>::key_equal, typename Allocator = typename std::unordered_map<Key, Value>::allocator_type> #endif using FlatHashMap = std::unordered_map<Key, Value, Hash, Equal, Allocator>; struct S { }; struct Hash { std::size_t operator==(const S&) const { return 0; } }; struct Eq { bool operator()(const S&, const S&) const { return true; } }; FlatHashMap<S, int, Hash, Eq> m; The problem is that the alias template FlatHashMap instantiates std::unordered_map<Key, Value> to obtain any of the Hash, Equal or Allocator types that are not provided explicitly. When used by PredictionContextMergeCache, the Hash and Equal types are provided explicitly (because antlr-cpp has custom hasher and comparison types for the map's key type). But the Allocator type is not provided, so it uses the default template argument, which is: std::unordered_map<Key, Value>::allocator_type This triggers the instantiation of std::unordered_map<Key, Value> which uses *its* default hasher, which is std::hash<Key>, which is invalid, which triggers the static_assert. That instantiation isn't actually wanted, they never use it, they're just trying to get some nested types out of it. The commit referenced in comment 12 avoids instantiating it just to get some types that can be obtained far more directly than by instantiating an unusable specialization of std::unordered_map. Basically the same problem as they encountered upstream with a static_assert that I added (and then I think reverted) in GCC 7: https://github.com/antlr/antlr4/pull/3885