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'


Jakub Jelinek <jakub@redhat.com> writes:

| On Wed, May 23, 2001 at 09:55:31AM -0700, Mark Mitchell wrote:
| >     Jakub> As I already wrote, this is especially bad in the global
| >     Jakub> namespace, because there the library has hard time to take
| >     Jakub> care of all the global namespace functions. Like:
| > 
| > We already do not put these names in the global namespace.
| 
| Really? As I see bits/c_std/ it puts everything into global namespace and
| then drags them into the std:: namespace.

Well, it should be pointed out the whole thing in bits/c_std is not in
its final shape (speaking politicallyy correctly, it is broken); so I
can't accept your argument.


| >     Jakub> #include <cstring>
| > 
| >     Jakub> using namespace std;
| > 
| >     Jakub> int foo () { return strchr ("abc", 'a') != 0; }
| > 
| >     Jakub> will not be optimized while if it is replaced by
| >     Jakub> std::strchr it will (although as soon as those builtins are
| > 
| > This one uses the one in `std', thanks to the `using', so it will be
| > treated just like `std::strchr'.  And the library can easily make
| > `std::strchr' call `std::__builtin_strchr' just as it does for
| > `std::fabs'.
| 
| So how do you explain that
| 
| #include <cstring>
| 
| using namespace std;
| 
| int foo () { return strchr ("abc", 'a') != 0; }
| 
| is not optimized while
| 
| #include <cstring>
| 
| using namespace std;
| 
| int foo () { return std::strchr ("abc", 'a') != 0; }
| 
| is?

Because the library is not working correctly.

| > In C++, there is no such standard function as `::strchr', and it would
| > be wrong to optimize it specially.  A user program like:
| 
| But the C++ standard includes implicitely ISO C standard which defines what
| strchr does.

However Standard C++ is clear about -how- those functions are
supplied.  It is far from being an obvious thing.  Mark's analysis is
right. 

-- Gaby


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