https://gcc.gnu.org/bugzilla/show_bug.cgi?id=77271

            Bug ID: 77271
           Summary: flag -std=c++98 cannot set _GLIBCXX_USE_CXX11_ABI
                    properly
           Product: gcc
           Version: 5.4.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: frast at mail dot spbnit.ru
  Target Milestone: ---

I have a library compiled by previous version of G++ with default -std=c++98

Building an executable with default flags for 4.8.5 produces unresolved
symbols:
..... undefined reference to
`libebml::EbmlString::operator=(std::__cxx11::basic_string<char,
std::char_traits<char>, std::allocator<char> > const&)'

The problem has been resolved by adding -std=c++98 flag.

The same problem has been detected with gcc version 5.4.0 20160609 (Ubuntu
5.4.0-6ubuntu1~16.04.2)

My investigation of the problem shows, that the problem in the file
/usr/include/x86_64-linux-gnu/c++/5.4.0/bits/c++config.h
lines 194-234
=================================== cut ===================================
namespace std
{
  typedef __SIZE_TYPE__         size_t;
  typedef __PTRDIFF_TYPE__      ptrdiff_t;

#if __cplusplus >= 201103L
  typedef decltype(nullptr)     nullptr_t;
#endif
}

# define _GLIBCXX_USE_DUAL_ABI 1

#if ! _GLIBCXX_USE_DUAL_ABI
// Ignore any pre-defined value of _GLIBCXX_USE_CXX11_ABI
# undef _GLIBCXX_USE_CXX11_ABI
#endif

#ifndef _GLIBCXX_USE_CXX11_ABI
# define _GLIBCXX_USE_CXX11_ABI 1
#endif

#if _GLIBCXX_USE_CXX11_ABI
namespace std
{
  inline namespace __cxx11 __attribute__((__abi_tag__ ("cxx11"))) { }
}
namespace __gnu_cxx
{
  inline namespace __cxx11 __attribute__((__abi_tag__ ("cxx11"))) { }
}
# define _GLIBCXX_NAMESPACE_CXX11 __cxx11::
# define _GLIBCXX_BEGIN_NAMESPACE_CXX11 namespace __cxx11 {
# define _GLIBCXX_END_NAMESPACE_CXX11 }
# define _GLIBCXX_DEFAULT_ABI_TAG _GLIBCXX_ABI_TAG_CXX11
#else
# define _GLIBCXX_NAMESPACE_CXX11
# define _GLIBCXX_BEGIN_NAMESPACE_CXX11
# define _GLIBCXX_END_NAMESPACE_CXX11
# define _GLIBCXX_DEFAULT_ABI_TAG
#endif
=================================== end cut ===================================

Independent of the key '-std=' this file sets to _GLIBCXX_USE_CXX11_ABI = 1

I have fixed this problem by using '-std=c++98 -D_GLIBCXX_USE_CXX11_ABI=0'

But probably it will be better apply a patch for all comunity

=================================== cut ===================================
***************
***************
*** 207,215 ****
  // Ignore any pre-defined value of _GLIBCXX_USE_CXX11_ABI
  # undef _GLIBCXX_USE_CXX11_ABI
  #endif

! #ifndef _GLIBCXX_USE_CXX11_ABI
  # define _GLIBCXX_USE_CXX11_ABI 1
  #endif

  #if _GLIBCXX_USE_CXX11_ABI
--- 207,217 ----
  // Ignore any pre-defined value of _GLIBCXX_USE_CXX11_ABI
  # undef _GLIBCXX_USE_CXX11_ABI
  #endif

! #if __cplusplus < 201103L
! # define _GLIBCXX_USE_CXX11_ABI 0
! #elif ! defined(_GLIBCXX_USE_CXX11_ABI)
  # define _GLIBCXX_USE_CXX11_ABI 1
  #endif
=================================== end cut ===================================

Thanks.

Reply via email to