This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Builtins in `std'
- To: gcc at gcc dot gnu dot org, Jason Merrill <jason at cygnus dot com>, Benjamin Kosnik <bkoz at nabi dot net>, Gabriel Dos Reis <gdr at codesourcery dot com>, Nathan Sidwell <nathan at codesourcery dot com>
- Subject: Builtins in `std'
- From: Mark Mitchell <mark at codesourcery dot com>
- Date: Tue, 22 May 2001 20:03:02 -0700
- Organization: CodeSourcery, LLC
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