This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


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

Re: Builtins in `std'


On 23-May-2001, Mark Mitchell <mark@codesourcery.com> wrote:
> >>>>> "Fergus" == Fergus Henderson <fjh@cs.mu.oz.au> writes:
> 
>     Fergus> There is no standard function named `::strchr', but
>     Fergus> nevertheless `::strchr' is reserved.  This means that
>     Fergus> implementations are free to allow user programs like that,
>     Fergus> but are not required to do so.
> 
> Do you think `static char *strchr (const char*, int) {...}' is OK?

No.  Nor do I think

	static int strchr;

or

	typedef int strchr;

is OK.  As I interpret the standard, they all have undefined behaviour,
because the name "strchr" is reserved for use as a name of namespace
scope in the global namespace (the relevant text is 17.4.3.1.3/5, which
I quoted earlier).

The text is a little ambiguous, though; it says the "_function
signature_ ...  is reserved ... for use ... as a _name_ of namespace
scope", which doesn't quite make sense, since a function signature
isn't a name.  I'm not sure exactly what was intended here.

But I think the rationale for reserving these names is to make it easier
for implementors who want to implement the C++ library headers by #including
 the C library headers.  However, the committee did not go so far as to
make things really easy; you can't write a portable C++ library on top of a C
library using only those features that the standard provides.

-- 
Fergus Henderson <fjh@cs.mu.oz.au>  |  "I have always known that the pursuit
                                    |  of excellence is a lethal habit"
WWW: <http://www.cs.mu.oz.au/~fjh>  |     -- the last words of T. S. Garp.


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