This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

[g++] namespace problem


Hi,

  I'm working on the C compatibility headers for libstdc++-v3
(process detailed: http://www.cantrip.org/cheaders.html). There appears
to be a buglet floating around somewhere in the compiler system that
(,I believe, wrongly) finds ambiguity with function calls defined
in separate namespaces.

compiling the attached program results in the following:

  brent$ g++ screwy-namespaces.cc -o screwy-namespaces
  screwy-namespaces.cc: In function `int main ()':
  screwy-namespaces.cc:31: call of overloaded `abs (int)' is ambiguous
  <internal>:31: candidates are: int abs (int)
  screwy-namespaces.cc:19:                 int std::abs (int)

Where does the <internal> come from?

Also, I have attached the output from 'g++ -E -dD'

Thanks for your help,
  Brent

-- 
Damon Brent Verner                        o      _     _         _
Cracker JackŪ Surprise Certified  _o     /\_   _ \\o  (_)\__/o  (_)
brent@rcfile.org                _< \_   _>(_) (_)/<_    \_| \   _|/' \/
brent@linux1.org               (_)>(_) (_)        (_)   (_)    (_)'  _\o_

namespace _C_ {
  extern "C" {
#   include <stdlib.h>
    extern int this_works(int a);
  }
  inline int _X_this_works(int a)
    { return this_works(a); }
  inline int _X_abs( int a )
    { return abs(a); }
}

namespace std {
#if 0
  using ::_C_::abs;
  using ::_C_::this_works;
#else
  inline int abs( int a )
    { return ::_C_::_X_abs(a); }
  inline int this_works(int a)
    { return ::_C_::_X_this_works(a); }
#endif
}

using namespace std;

int
main()
{
  this_works(1);
  abs(1); // this doesn't :(
}

screwy-namespaces.ii.gz


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]