https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114600
Bug ID: 114600
Summary: [modules] redefinition errors when using certain std
headers in GMF
Product: gcc
Version: 14.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: m.cencora at gmail dot com
Target Milestone: ---
$ cat std.cpp
module;
#include <type_traits>
export module std;
$ cat main.cpp
import std;
#include <type_traits>
int main()
{
}
$ g++ -std=c++20 -fmodules-ts -c std.cpp
$ g++ -std=c++20 -fmodules-ts main.cpp -o main
In file included from main.cpp:3:
/usr/include/c++/14/type_traits:89:36: error: template definition of
non-template ‘constexpr const _Tp std::integral_constant<_Tp, __v>::value’
89 | static constexpr _Tp value = __v;
| ^~~
/usr/include/c++/14/type_traits:90:29: error: template definition of
non-template ‘using std::integral_constant<_Tp, __v>::value_type = _Tp’
90 | using value_type = _Tp;
| ^
/usr/include/c++/14/type_traits:91:47: error: template definition of
non-template ‘using std::integral_constant<_Tp, __v>::type = struct
std::integral_constant<_Tp, __v>’
91 | using type = integral_constant<_Tp, __v>;
| ^
/usr/include/c++/14/type_traits:92:45: error: template definition of
non-template ‘constexpr std::integral_constant<_Tp, __v>::operator value_type()
const’
92 | constexpr operator value_type() const noexcept { return value; }
| ^~~~~~~~
/usr/include/c++/14/type_traits:95:47: error: template definition of
non-template ‘constexpr std::integral_constant<_Tp, __v>::value_type
std::integral_constant<_Tp, __v>::operator()() const’
95 | constexpr value_type operator()() const noexcept { return value;
}
| ^~~~~~~~
/usr/include/c++/14/type_traits:963:26: error: redefinition of default argument
for ‘class _Up’
963 | template<typename _Tp, typename _Up = _Tp&&>
| ^~~~~~~~
In file included from std.cpp:3,
of module std, imported at main.cpp:1:
/usr/include/c++/14/type_traits:963:26: note: original definition appeared here
963 | template<typename _Tp, typename _Up = _Tp&&>
| ^~~~~~~~
/usr/include/c++/14/type_traits:2470:10: error: redefinition of ‘template<class
_Tp> decltype (__declval<_Tp>(0)) std::declval()’
2470 | auto declval() noexcept -> decltype(__declval<_Tp>(0))
| ^~~~~~~
/usr/include/c++/14/type_traits:2470:10: note: ‘template<class _Tp> decltype
(__declval<_Tp>(0)) std::declval@std()’ previously declared here
===
Seems like merging of GMFs does not work sometimes.
Also if I create a preprocessed file for <type_traits>
$ g++- -std=c++20 -fmodules-ts -x c++-system-header -E type_traits -o
common.hpp
and include this "common.hpp" instead of <type_traits> in both cpp files, then
compilation succeeds.
This works fine on gcc-13 (at least for <type_traits> header)