std::list implementation define _GLIBCXX20_ONLY incorrectly

廖 弘毅 <[email protected]>
Newsgroups gmane.comp.lib.newlib
Message-ID <[email protected]>
In file bits/list.tcc, the _GLIBCXX20_ONLY is declared as forward if __cplusplus > 201703L, but in bits/stl_list.h the __remove_return_type is declared as size_type if __glibcxx_list_remove_return_type. Thus when building in freestanding mode, the return statements would cause errors.

gcc 14.2 newlib 4.4.0.20231231
host x86_64-linux-elf target i686-elf freestanding
I’ve defined _REQUIRES_FREESTANDING_H before the header to bypass bits/requires_hosted.h restriction.

bits/stl_list.h

#ifdef __glibcxx_list_remove_return_type // C++ >= 20 && HOSTED
      typedef size_type __remove_return_type;
# define _GLIBCXX_LIST_REMOVE_RETURN_TYPE_TAG \
      __attribute__((__abi_tag__("__cxx20")))
#else
      typedef void __remove_return_type;
# define _GLIBCXX_LIST_REMOVE_RETURN_TYPE_TAG
#endif

bits/list.tcc

#if __cplusplus > 201703L
# define _GLIBCXX20_ONLY(__expr) __expr
#else
# define _GLIBCXX20_ONLY(__expr)
#endif
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.