https://gcc.gnu.org/bugzilla/show_bug.cgi?id=124428
--- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> --- (In reply to Jonathan Wakely from comment #0) > Currently <vector> includes bits/version.h 12 times! (That's for -std=gnu++20 so it's probably more than 12 times in -std=gnu++26 mode). The changes proposed above wouldn't really help much though, the re-includes come from: # 40 "/home/jwakely/gcc/16/include/c++/16.0.1/bits/cpp_type_traits.h" 3 # 1 "/home/jwakely/gcc/16/include/c++/16.0.1/bits/version.h" 1 3 # 69 "/home/jwakely/gcc/16/include/c++/16.0.1/type_traits" 3 # 1 "/home/jwakely/gcc/16/include/c++/16.0.1/bits/version.h" 1 3 # 40 "/home/jwakely/gcc/16/include/c++/16.0.1/compare" 3 # 1 "/home/jwakely/gcc/16/include/c++/16.0.1/bits/version.h" 1 3 # 38 "/home/jwakely/gcc/16/include/c++/16.0.1/concepts" 3 # 1 "/home/jwakely/gcc/16/include/c++/16.0.1/bits/version.h" 1 3 # 44 "/home/jwakely/gcc/16/include/c++/16.0.1/new" 2 3 # 1 "/home/jwakely/gcc/16/include/c++/16.0.1/bits/version.h" 1 3 # 63 "/home/jwakely/gcc/16/include/c++/16.0.1/bit" 3 # 1 "/home/jwakely/gcc/16/include/c++/16.0.1/bits/version.h" 1 3 # 37 "/home/jwakely/gcc/16/include/c++/16.0.1/numbers" 3 # 1 "/home/jwakely/gcc/16/include/c++/16.0.1/bits/version.h" 1 3 # 42 "/home/jwakely/gcc/16/include/c++/16.0.1/bits/ranges_base.h" 2 3 # 1 "/home/jwakely/gcc/16/include/c++/16.0.1/bits/version.h" 1 3 # 88 "/home/jwakely/gcc/16/include/c++/16.0.1/vector" 3 # 1 "/home/jwakely/gcc/16/include/c++/16.0.1/bits/version.h" 1 3 # 53 "/home/jwakely/gcc/16/include/c++/16.0.1/cstddef" 2 3 # 1 "/home/jwakely/gcc/16/include/c++/16.0.1/bits/version.h" 1 3 # 37 "/home/jwakely/gcc/16/include/c++/16.0.1/bits/uses_allocator_args.h" 3 # 1 "/home/jwakely/gcc/16/include/c++/16.0.1/bits/version.h" 1 3 # 57 "/home/jwakely/gcc/16/include/c++/16.0.1/tuple" 3 # 1 "/home/jwakely/gcc/16/include/c++/16.0.1/bits/version.h" 1 3 So most of these (type_traits, compare, concepts, new, bit, numbers, vector, cstddef, tuple) are standard headers that need to include bits/version.h in order to define one or more public __cpp_lib_xxx macros. Only three (cpp_type_traits.h, ranges_base.h, uses_allocator_args.h) are including the header just to get the internal macros. So we would only be able to reduce it to being included 10 times, which is hardly an improvement. (It would be good if <vector> didn't need to include all of <numbers> just so that max_diff_type.h can use ln2 and ln10 constants, and didn't need all of <tuple> just because the pmr::vector alias uses pmr::polymorphic_allocator which does uses-allocator construction, and didn't need all of <bit> just because stl_algobase.h uses __bit_width ... but that's a bigger refactoring project.)
