This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
[RFC] middle-end/21743: Enable __builtin_clog
- From: Paolo Carlini <pcarlini at suse dot de>
- To: libstdc++ <libstdc++ at gcc dot gnu dot org>
- Cc: "Kaveh R. Ghazi" <ghazi at caip dot rutgers dot edu>,Roger Sayle <roger at eyesopen dot com>
- Date: Fri, 27 May 2005 13:21:29 +0200
- Subject: [RFC] middle-end/21743: Enable __builtin_clog
Hi,
I'm trying to figure out whether we can resolve this annoying issue one
way or another... A short summary. Some time ago Kaveh setup everything
related to the C99 builtins and now we have a complete set available,
besides (builtins.def):
/* The C99 clog function conflicts with C++ iostreams clog, see
http://gcc.gnu.org/ml/gcc-patches/2003-09/msg00510.html */
...
...
/*DEF_C99_BUILTIN (BUILT_IN_CLOG, "clog",
BT_FN_COMPLEX_DOUBLE_COMPLEX_DOUBLE, ATTR_MATHFN_FPROUNDING)*/
/*DEF_C99_BUILTIN (BUILT_IN_CLOGF, "clogf",
BT_FN_COMPLEX_FLOAT_COMPLEX_FLOAT, ATTR_MATHFN_FPROUNDING)*/
/*DEF_C99_BUILTIN (BUILT_IN_CLOGL, "clogl",
BT_FN_COMPLEX_LONGDOUBLE_COMPLEX_LONGDOUBLE, ATTR_MATHFN_FPROUNDING)*/
The problem is that this kind of builtin injects in the global namespace
also the version without __builtin_* in front and we get a conflict with
the C++ runtime library as soon as the user does, in the gloobal namespace:
using std::clog;
Now, as you easily see, it would be great to enable that remaining
builtin, both for consistency and, in practice, for use in the C++
runtime library itself: the implementation of std::complex::log could
nicely exploit it, the same that is already happening for the other C99
complex functions.
What can we realistically do? Some considerations:
- Andrew suggested enabling only the __builtin_* version of those
builtins. From my selfish C++ runtime point of view, would be ok, but
then we have to invent a new kind of DEF_*_BUILTIN macro, having both
BOTH_P == false and FALLBACK_P == true. Maybe, short-term is better than
what we currently have.
Now, there is something that I don't understand *at all* in the C99
builtins machinery itself... If I try to enable __builtin_clog, the
following doesn't compile:
#include <iostream>
using std::clog;
clog1.cc:2: error: 'clog' is already declared in this scope
And *also* this one doesn't compile:
int main()
{
_Complex double a;
clog(a);
}
clog2.cc:4: error: 'clog' was not declared in this scope
???
Is clog - the complex mathematical function - declared or not?!?
I mean, in general, the C99 builtins machinery does *not* inject names
without __builtin_* in the global namespace (second example). So far, so
very good. But then, why I cannot bring in the global namespace itself
my std::clog (first example)?!?
Anyone willing to clarify or suggest solutions at any level?!?
Thanks for now, back to the shell...
Paolo.