[PATCH] libstdc++: make forward declarations of std::list overloads of __distance use consistent inline specifications

Avi Kivity avi@lists.scylladb.com
Sat Dec 5 19:16:06 GMT 2026


From: Avi Kivity <avi@scylladb.com>

stl_iterator_base_funcs.h forward-declares some overloads of __distance
without the inline specifier, while the definitions in stl_list.h are
inline. This is a violation of the One Definition Rule, No Diagnostic
Required. Normally it isn't a problem but it does trip up Clang's module
machinery. Since it's a bug, we fix it here by adding the missing inlines.

Assisted-by: Claude Opus 5.5
Signed-off-by: Avi Kivity <avi@scylladb.com>

While Claude did the heavy lifting, the patch was fully authored by me.

libstdc++-v3/ChangeLog:

	PR libstdc++/129332
	* libstdc++-v3/include/bits/stl_iterator_base_funcs.h: mark
	__distance() forward declarations inline.
---
 libstdc++-v3/include/bits/stl_iterator_base_funcs.h | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/libstdc++-v3/include/bits/stl_iterator_base_funcs.h b/libstdc++-v3/include/bits/stl_iterator_base_funcs.h
index e6c10601432..780a6409c55 100644
--- a/libstdc++-v3/include/bits/stl_iterator_base_funcs.h
+++ b/libstdc++-v3/include/bits/stl_iterator_base_funcs.h
@@ -110,16 +110,18 @@ _GLIBCXX_END_NAMESPACE_CONTAINER
     }
 
 #if _GLIBCXX_USE_CXX11_ABI
   // Forward declaration because of the qualified call in distance.
   template<typename _Tp>
+    inline
     ptrdiff_t
     __distance(_GLIBCXX_STD_C::_List_iterator<_Tp>,
 	       _GLIBCXX_STD_C::_List_iterator<_Tp>,
 	       input_iterator_tag);
 
   template<typename _Tp>
+    inline
     ptrdiff_t
     __distance(_GLIBCXX_STD_C::_List_const_iterator<_Tp>,
 	       _GLIBCXX_STD_C::_List_const_iterator<_Tp>,
 	       input_iterator_tag);
 #endif
-- 
2.56.1



More information about the Libstdc++ mailing list