This is the mail archive of the libstdc++@sources.redhat.com mailing list for the libstdc++ 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


> 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

I believe it should have detected much earlier that they are indeed
the same function: when building the candidates list, duplicates are
eliminated. It would be best if ::fabs and std::fabs would be the same
DECL, which should have a DECL_CONTEXT of std:: (if std is honoured).

To achieve this, I believe cp/decl.c:builtin_function should put
*some* declarations into std::. Specifically, the __builtin_*
functions probably need to be globally visible, whereas the functions
mandated by the C++ standard's standard C library should be in std::.
To achieve this, additional classes (along with BUILT_IN_NORMAL)
might be needed, or builtin_function could do magic with looking at
the name of the function.

>   A) in joust() to arbitrarily choose one when the functions differ 
>        only in CONTEXT_DECL? how would I verify this condition?

No! If that was done, it would do the wrong thing for

namespace Foo{
  struct Bar{};
  void foobar(Bar*);
}
void foobar(Foo::Bar*);

Calling foobar(new Foo::Bar) is ambiguous and must be reported as such.

>   B) elsewhere to ensure that the the ::__builtin_fn is not a candidate
>        at all. where would this be done?

It is ok if they are candidates - just not more than once.

>   C) remove the gcc source from my box and take a real vacation :-)

Sounds like a good plan to me :=)

Regards,
Martin

P.S. As a side note: functions should be considered equivalent if they
have the same name and are both extern "C". I'm not sure whether this
is done correctly.

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