Ticket Hash: 8ee003badda1c6033919702ac729de7c00ceb6b1
Title: GCC - ambiguous reference to namespace when #include <list>
Status: Fixed Type: Code_Defect
Severity: Important Priority: Immediate
Subsystem: Resolution: Open
Last Modified: 2021-09-27 18:24:41
Version Found In: all
User Comments:
luismachuca added on 2014-12-30 17:16:50:

Code written to use cxxomfort and the <list> header triggers the following compilation error with GCC in C++03 mode (example):

/usr/include/c++/4.7/bits/stl_list.h:107:32: error: reference to ‘__detail’ is ambiguous
/usr/include/c++/4.7/bits/stl_list.h:68:3: error: candidates are: namespace std::__detail { }

which triggers a cascade of errors regarding "__List_Base" as a result.

Tested in GCC 4.5, 4.6 and 4.7 without `--std=c++0x`.


luismachuca added on 2015-07-30 17:04:04:

When #include-ing <list> with GCC in C++03 mode, the following error happens:

In file included from /usr/include/c++/4.8/list:63:0,
                 from prueba-seq.cpp:5:
/usr/include/c++/4.8/bits/stl_list.h:106:32: error: reference to ‘__detail’ is ambiguous
     struct _List_node : public __detail::_List_node_base
                                ^
/usr/include/c++/4.8/bits/stl_list.h:67:3: note: candidates are: namespace std::__detail { }
   {
   ^
In file included from /usr/include/c++/4.8/tr1/gamma.tcc:49:0,
                 from /usr/include/c++/4.8/tr1/cmath:1016,
                 from /usr/local/include/tr1_fwd/cmath:5,
                 from /usr/include/c++/4.8/valarray:37,
                 from /usr/local/include/cxxomfort/./base/iterator.hpp:278,
                 from /usr/local/include/cxxomfort/base.hpp:17,
                 from /usr/local/include/cxxomfort/cxxomfort.hpp:41,
                 from prueba-seq.cpp:3:
/usr/include/c++/4.8/tr1/special_function_util.h:44:3: note:                 namespace std::tr1::__detail { }
   {
   ^
In file included from /usr/include/c++/4.8/list:63:0,
                 from prueba-seq.cpp:5:
/usr/include/c++/4.8/bits/stl_list.h:106:32: error: reference to ‘__detail’ is ambiguous
     struct _List_node : public __detail::_List_node_base
                                ^
/usr/include/c++/4.8/bits/stl_list.h:67:3: note: candidates are: namespace std::__detail { }
   {
   ^
In file included from /usr/include/c++/4.8/tr1/gamma.tcc:49:0,
                 from /usr/include/c++/4.8/tr1/cmath:1016,
                 from /usr/local/include/tr1_fwd/cmath:5,
                 from /usr/include/c++/4.8/valarray:37,
                 from /usr/local/include/cxxomfort/./base/iterator.hpp:278,
                 from /usr/local/include/cxxomfort/base.hpp:17,
                 from /usr/local/include/cxxomfort/cxxomfort.hpp:41,
                 from prueba-seq.cpp:3:
/usr/include/c++/4.8/tr1/special_function_util.h:44:3: note:                 namespace std::tr1::__detail { }
   {
   ^

Or similar errors.

These are due to the implementation in stl_list.h issuing a "using namespace tr1" statement at the detail level, creating ambiguous references.

  • Using namespace for TR1 is a design decision for cxxomfort, so this might be unavoidable.
  • Other projects have reported similar error so this is an issue with TR1 (link pending).
  • Recommended option would be to manually pach stl_list.h.
  • Alternative option would be to avoid using.hpp and manually using all TR1 names; this might be unworkable or end up Boost-like when tending to specific compiler / toolkit versions.


luismachuca added on 2021-09-27 18:24:41:
Fixed early in >=2020-01-01 versions.