This is the mail archive of the gcc-bugs@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: [3.0 regression] libstdc++ and strstr


>| #include <stdio.h>
>| 
>| extern "C" void foo (const char* __s);
>| 
>| namespace bar
>| {
>| extern "C" inline void foo (const char* __s) { printf ("const\n"); }
>| inline void foo (char* __s) { printf ("non-const\n"); }
>| }
>| 
>| int main ()
>| {
>|   char* s = "l";

> This won't work.

I don't understand your short comment at all since it doesn't explain
what is wrong with the code.  In any event, if you think the entire
technique shouldn't work, then be aware that exact general technique
for handling overloading of a C name is already employed in
libstdc++-v3/include/c_std/bits/std_cstdlib.h and I found example code
in the standard that makes me think it is quite legitimate.

If you think that ``extern "C" inline'' doesn't work, then I might
agree with you.  However, that was done only to provide a quick
working self-contained example.  I think I agree that it shouldn't
work if foo was an actual C name provided by an actual C library
implementation that we were layered atop.  The current usage in the
libstdc++-v3 does not provide an inline function for the copy of the
function provided by the C Standard only the newly added C++ overloads
of that name.

Given where you choose to stop quoting the example I provided, I think
your comment relates to the final quoted line.

If you think only the final quoted line is in error and won't work,
then I have two answers for you: (1) that line was not pertaining to
the validity of the general overloading technique being displayed; (2)
please see section C.1.1 clause 4.  That exact form of code is
displayed as legal but deprecated in C++.

Regards,
Loren


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