mardi 13 avril 2021

g++ including iostream gives a compilation error on a nearly identical system, why?

Weird issue, I have two systems, CentOS Linux release 8.3.2011, and they are nearly identical from a package standpoint, everything that's installed on one is also installed on the other, with minor exceptions, none of them related to gcc versions.

# gcc --version
gcc (GCC) 8.3.1 20191121 (Red Hat 8.3.1-5)

# ld --version
GNU ld version 2.30-79.el8

# ldd --version
ldd (GNU libc) 2.28

However, when I try to compile a simple c++ program:

#include <iostream>

int main(void)
{
        return 0;
}

I get the following error [1]. Any ideas, how to narrow down the issue? I tried reinstalling gcc and gcc-c++ packages.

# g++ test_c11_v2.c++
In file included from /usr/include/c++/8/string:52,
                 from /usr/include/c++/8/bits/locale_classes.h:40,
                 from /usr/include/c++/8/bits/ios_base.h:41,
                 from /usr/include/c++/8/ios:42,
                 from /usr/include/c++/8/ostream:38,
                 from /usr/include/c++/8/iostream:39,
                 from test_c11_v2.c++:1:
/usr/include/c++/8/bits/basic_string.h: In static member function ‘static int std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::_S_compare(std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::size_type, std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::size_type)’:
/usr/include/c++/8/bits/basic_string.h:394:46: error: ‘__max’ is not a member of ‘__gnu_cxx::__numeric_traits<int>’
  if (__d > __gnu_cxx::__numeric_traits<int>::__max)
                                              ^~~~~
/usr/include/c++/8/bits/basic_string.h:395:45: error: ‘__max’ is not a member of ‘__gnu_cxx::__numeric_traits<int>’
    return __gnu_cxx::__numeric_traits<int>::__max;
                                             ^~~~~
/usr/include/c++/8/bits/basic_string.h:396:51: error: ‘__min’ is not a member of ‘__gnu_cxx::__numeric_traits<int>’
  else if (__d < __gnu_cxx::__numeric_traits<int>::__min)
                                                   ^~~~~
/usr/include/c++/8/bits/basic_string.h:397:45: error: ‘__min’ is not a member of ‘__gnu_cxx::__numeric_traits<int>’
    return __gnu_cxx::__numeric_traits<int>::__min;
                                             ^~~~~
In file included from /usr/include/c++/8/bits/basic_string.h:6400,
                 from /usr/include/c++/8/string:52,
                 from /usr/include/c++/8/bits/locale_classes.h:40,
                 from /usr/include/c++/8/bits/ios_base.h:41,
                 from /usr/include/c++/8/ios:42,
                 from /usr/include/c++/8/ostream:38,
                 from /usr/include/c++/8/iostream:39,
                 from test_c11_v2.c++:1:
/usr/include/c++/8/ext/string_conversions.h: In static member function ‘static bool __gnu_cxx::__stoa(_TRet (*)(const _CharT*, _CharT**, _Base ...), const char*, const _CharT*, std::size_t*, _Base ...)::_Range_chk::_S_chk(_TRet, std::true_type)’:
/usr/include/c++/8/ext/string_conversions.h:75:50: error: ‘__min’ is not a member of ‘__gnu_cxx::__numeric_traits<int>’
      return __val < _TRet(__numeric_traits<int>::__min)
                                                  ^~~~~
/usr/include/c++/8/ext/string_conversions.h:76:48: error: ‘__max’ is not a member of ‘__gnu_cxx::__numeric_traits<int>’
        || __val > _TRet(__numeric_traits<int>::__max);
                                                ^~~~~
In file included from /usr/include/c++/8/istream:991,
                 from /usr/include/c++/8/iostream:40,
                 from test_c11_v2.c++:1:
/usr/include/c++/8/bits/istream.tcc: In member function ‘std::basic_istream<_CharT, _Traits>& std::basic_istream<_CharT, _Traits>::operator>>(int&)’:
/usr/include/c++/8/bits/istream.tcc:183:52: error: ‘__min’ is not a member of ‘__gnu_cxx::__numeric_traits<int>’
        if (__l < __gnu_cxx::__numeric_traits<int>::__min)
                                                    ^~~~~
/usr/include/c++/8/bits/istream.tcc:186:45: error: ‘__min’ is not a member of ‘__gnu_cxx::__numeric_traits<int>’
     __n = __gnu_cxx::__numeric_traits<int>::__min;
                                             ^~~~~
/usr/include/c++/8/bits/istream.tcc:188:57: error: ‘__max’ is not a member of ‘__gnu_cxx::__numeric_traits<int>’
        else if (__l > __gnu_cxx::__numeric_traits<int>::__max)
                                                         ^~~~~
/usr/include/c++/8/bits/istream.tcc:191:45: error: ‘__max’ is not a member of ‘__gnu_cxx::__numeric_traits<int>’
     __n = __gnu_cxx::__numeric_traits<int>::__max;
                                             ^~~~~

Aucun commentaire:

Enregistrer un commentaire