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]

Re: [c++] builtin functions and namespaces


On 26 Sep 2000 at 09:24 (-0700), Benjamin Kosnik wrote:
| 
| Brent, we can go with just this slightly simplified example:
| 
| // start
| namespace _C_ {
|   extern "C" {
|     extern int abs(int a);
|   }
| }
| namespace std {
|   using ::_C_::abs;
| }
| 
| using namespace std;
| 
| int
| main()
| {
|   abs(1);
| }
| // end
| 
| %eccp --strict kill.cc

what is this prog?

| %g++ -c -fno-builtin kill.cc
| 
| %g++ -c kill.cc
| kill.cc:8: `abs' is already declared in this scope
| kill.cc: In function `int main ()':
| kill.cc:16: `abs' undeclared (first use this function)
| kill.cc:16: (Each undeclared identifier is reported only once for each 
| function it appears in.)

does that g++ default to '-fhonor-std'? ... as I get the above error 
with '-fno-honor-std' on my g++

The error I'm getting is:

brent@dust$ g++ x.cc -o x
x.cc: In function `int main ()':
x.cc:15: call of overloaded `abs (int)' is ambiguous 
<internal>:15: candidates are: int abs (int)
x.cc:3:                 int _C_::abs (int)

| This appears to be a bug or limitation of g++. Jason, Martin, what are
| the options for namespace-using libraries such as libstdc++-v3? Should
| we default to not using builtins for the moment? It would be nice for
| this to work in a similar manner with and without builtins.

if the builtin/namespace issue is not to be resolved soon, should 
g++ default to 'fno-builtin' when configure gets 
--enable-cshadow-headers?

I've spent some time in gcc/gcc/cp/ digging for the cause of this bug,
and am now somewhat familiar with the code, but I've obviously not
found the solution, so if one of you could point me in the direction 
of the solution, I might be able to pull it off.

now I'll ramble...

gcc/cp/call.c: build_new_function_call()
  which kicks the error because
gcc/cp/call.c: tourney()
  returns 0 because
gcc/cp/call.c: joust()
  returns 0 because joust can't decide whether to pick the 
  ::std::__builtin_fn or ::__buitlin_fn as the better candidate

my question is this.
is it best to make changes:
  A) in joust() to arbitrarily choose one when the functions differ 
       only in CONTEXT_DECL? how would I verify this condition?
  B) elsewhere to ensure that the the ::__builtin_fn is not a candidate
       at all. where would this be done?
  C) remove the gcc source from my box and take a real vacation :-)

seriously, I'm very interested in what the eventual solution will be,
so if you know the fix, or could help point me toward it, I'd appreciate
the lesson.

ideas, assistance, caffeine, popcorn?

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

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