https://gcc.gnu.org/bugzilla/show_bug.cgi?id=120005
Bug ID: 120005 Summary: TU-local exposure error in constexpr function Product: gcc Version: 15.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: marcel at laverdet dot com Target Milestone: --- I'm receiving a new TU-local exposure error under modules in gcc 15.1.0 which didn't appear before in gcc 14. Minimal test case is below. This error only occurs if the function declared in the header file is constexpr, the variable can be const or constexpr. root[18:56:11] [/workspace] $ cat a.h constexpr int flag = 0; constexpr bool check() { return flag == 0; } root[18:57:41] [/workspace] $ cat a.cc module; #include "a.h" export module M; export using ::check; root[18:57:54] [/workspace] $ gcc-14 -fmodules-ts -c a.cc # it compiles fine root[18:57:57] [/workspace] $ gcc-15 -fmodules-ts -c a.cc In file included from a.cc:2: a.h:2:16: error: 'constexpr bool check()' exposes TU-local entity 'flag' 2 | constexpr bool check() { | ^~~~~ a.h:1:15: note: 'flag' declared with internal linkage 1 | constexpr int flag = 0; | ^~~~ root[18:58:00] [/workspace] $ gcc-15 --version gcc-15 (Debian 15.1.0-1) 15.1.0 Copyright (C) 2025 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. --- I'm additionally seeing errors in a module which internally uses some boost containers. The case above is pared down from an unrelated header. The two issues seem related but in the boost case the function is not constexpr. I haven't had a chance to chop this up into a good reproduction but I thought I would raise it here in case it's the same and I can save the time. /usr/include/boost/container/vector.hpp:1305:3: error: ‘template<class T, class A, class Options> boost::container::vector<T, Allocator, Options>::vector(boost::container::vector<T, Allocator, Options>&&, const allocator_type&)’ exposes TU-local entity ‘boost::container::vector_uninitialized_size’ 1305 | vector(BOOST_RV_REF(vector) x, const allocator_type &a) | ^~~~~~ /usr/include/boost/container/vector.hpp:325:49: note: ‘boost::container::vector_uninitialized_size’ declared with internal linkage 325 | static inline const vector_uninitialized_size_t vector_uninitialized_size = | ^~~~~~~~~~~~~~~~~~~~~~~~~