Builtins in `std'
Mark Mitchell
mark@codesourcery.com
Tue May 22 20:03:00 GMT 2001
At startup, we push lots of builtins into `std'. For example, we do:
namespace std {
extern "C" double fabs (double);
};
This seems like a bad idea to me. For one thing, we accept the
following entirely bogus program:
void f() { std::fabs (3.0); }
This isn't C, where `void f() { fabs (3.0); }' is a legal program.
The compiler then has to go through tons of shenanigans if someone
tries to do something like:
namespace std {
int fabs;
};
or even:
namespace std {
double fabs (double); // Should no longer have `C' linkage.
};
Arguably, the former case should not be allowed, but the latter
probably should be. (Does V3 give `fabs' C or C++ linkage? The
standard says it's unspecified.)
There's no compatibility issue here, becuase we already broke:
void f() { fabs (3.0); }
by putting the builtins in the `std' namespace. Anyone writing a
standard library should be using `__builtin_fabs' anyhow for tidiness,
and I know that V3 does this.
So, any objections to just not doing the insertion into `std'?
--
Mark Mitchell mark@codesourcery.com
CodeSourcery, LLC http://www.codesourcery.com
More information about the Gcc
mailing list