Re: C++ Issue with const char * on strchr

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, Mar 10, 2009 at 09:42:24PM +0100, Jochen Schmitt wrote:
> Because this issue occurs only on gcc-4.4, I want to ask: is this
> a bug or a feature?

Feature.  ISO C++ mandates that std::strchr is overloaded:
char *strchr (char *, int);
const char *strchr (const char *, int);
and similarly for a whole bunch of other {str,mem,wcs}*
functions that return the first argument either unmodified or
with some offset added to it.  While the standard just talks about
std namespace and <cstring>/<cwchar> headers, gcc 4.4+ with glibc 2.10+
does that also in <string.h>/<wchar.h> for C++ (not doing it would lead to
different behaviour between
#include <string.h>
#include <cstring>
and
#include <cstring>
#include <string.h>
) and does that also for a bunch of GNU extensions where the overloading
makes sense.  The overloads make sense, these function no longer cast
away constness of pointed types, if you pass a char *, you get char *
back, if you pass const char *, you get const char * back.

	Jakub

-- 
fedora-devel-list mailing list
fedora-devel-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/fedora-devel-list

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Fedora Announce]     [Fedora Kernel]     [Fedora Testing]     [Fedora Formulas]     [Fedora PHP Devel]     [Kernel Development]     [Fedora Legacy]     [Fedora Maintainers]     [Fedora Desktop]     [PAM]     [Red Hat Development]     [Gimp]     [Yosemite News]
  Powered by Linux