[c++] builtin functions and namespaces
Kriang Lerdsuwanakij
lerdsuwa@usc.edu
Wed Sep 27 01:20:00 GMT 2000
> 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)
>
> 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 :-)
I suggest another solution. When a builtin function is declared as
extern
"C" in a namespace, we just record the namespace in the existing builtin
function. Doing this way, we only have one function candidate in
build_new_function_call(). So somewhere in grokfndecl or grokdeclarator
functions in decl.c are the places to look at.
--Kriang
More information about the Gcc-bugs
mailing list