public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
From: Peter Schmid <schmid@snake.iap.physik.tu-darmstadt.de>
To: gcc-gnats@gcc.gnu.org
Subject: libstdc++/2767: Problems with the new bits/std_cstring.h header
Date: Mon, 07 May 2001 12:36:00 -0000	[thread overview]
Message-ID: <200105072027.WAA02032@snake.iap.physik.tu-darmstadt.de> (raw)

>Number:         2767
>Category:       libstdc++
>Synopsis:       Problems with the new bits/std_cstring.h header
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Mon May 07 12:36:00 PDT 2001
>Closed-Date:
>Last-Modified:
>Originator:     Peter Schmid
>Release:        3.1 20010428 (experimental)
>Organization:
TU Darmstadt
>Environment:
System: Linux kiste 2.4.3 #35 Sat Mar 31 22:08:25 CEST 2001 i686 unknown
Architecture: i686
SuSE 7.1
Glibc 2.2
GNU ld version 2.11.90.0.4 (with BFD 2.11.90.0.4)
host: i686-pc-linux-gnu
build: i686-pc-linux-gnu
target: i686-pc-linux-gnu
configured with: ../gcc/configure --enable-shared --disable-nls --enable-threads=posix --enable-long-long --enable-languages=c,c++,f77,objc
>Description:
After the lines  

  extern "C" const char* strchr(const char*, int); 
  inline char*
  strchr(char* __s1, int __n)
  {
    return const_cast<char*>(strchr(const_cast<const char*>(__s1), __n));
  }
have been added to bits/std_cstring.h, the following source code td.C does
no longer compile. The same holds true, mutatis mutandis, for strstr, strrchr,
strpbrk, and  memchr. If I explicitly qualify strchr with the prefix
std:: or :: the code does compile. Though this behaviour may be legal,
it breaks a lot of code. Therefore, I kindly ask you to the fix the problem.

I destilled the code td.C from a large, ~1 Mbyte,
compilation unit from root which does compile with gcc 3.0.  

>How-To-Repeat:
Source file td.C

#include<cstring> //or #include<iostream> or #include <bits/std_cstring.h> 
using namespace std;

void f(const char *name)
{
    strchr(name,'/');
}

Compiling td.C
g++ -v -c td.C -W -Wall -save-temps 
Reading specs from /usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.1/specs
Configured with: ../gcc/configure --enable-shared --disable-nls --enable-threads=posix --enable-long-long --enable-languages=c,c++,f77,objc
Thread model: posix
gcc version 3.1 20010428 (experimental)
 /usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.1/cpp0 -lang-c++ -D_GNU_SOURCE -D__GNUG__=3 -D__DEPRECATED -D__EXCEPTIONS -D__GXX_ABI_VERSION=100 -v -D__GNUC__=3 -D__GNUC_MINOR__=1 -D__GNUC_PATCHLEVEL__=0 -D__ELF__ -Dunix -Dlinux -D__ELF__ -D__unix__ -D__linux__ -D__unix -D__linux -Asystem=posix -D__STDC_HOSTED__=1 -W -Wall -Acpu=i386 -Amachine=i386 -Di386 -D__i386 -D__i386__ -D__tune_i686__ -D__tune_pentiumpro__ td.C td.ii
GNU CPP version 3.1 20010428 (experimental) (cpplib) (i386 Linux/ELF)
#include "..." search starts here:
#include <...> search starts here:
 /usr/local/include/g++-v3
 /usr/local/include/g++-v3/i686-pc-linux-gnu
 /usr/local/include/g++-v3/backward
 /usr/local/include
 /usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.1/include
 /usr/local/i686-pc-linux-gnu/include
 /usr/include
End of search list.
 /usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.1/cc1plus -fpreprocessed td.ii -quiet -dumpbase td.C -W -Wall -version -o td.s
GNU CPP version 3.1 20010428 (experimental) (cpplib) (i386 Linux/ELF)
GNU C++ version 3.1 20010428 (experimental) (i686-pc-linux-gnu)
	compiled by GNU C version 3.1 20010428 (experimental).
td.C: In function `void f(const char*)':
td.C:6: call of overloaded `strchr(const char*&, char)' is ambiguous
/usr/include/string.h:155: candidates are: char* strchr(const char*, int)
/usr/local/include/g++-v3/bits/std_cstring.h:91:                 char* 
   std::strchr(char*, int) <near match>
/usr/local/include/g++-v3/bits/std_cstring.h:88:                 const char* 
   std::strchr(const char*, int)

Preprocessed source file td.ii

# 1 "td.C"
# 1 "/usr/local/include/g++-v3/cstring" 1 3

# 1 "/usr/local/include/g++-v3/bits/std_cstring.h" 1 3
# 39 "/usr/local/include/g++-v3/bits/std_cstring.h" 3
# 1 "/usr/local/include/g++-v3/i686-pc-linux-gnu/bits/c++config.h" 1 3
# 34 "/usr/local/include/g++-v3/i686-pc-linux-gnu/bits/c++config.h" 3
# 1 "/usr/local/include/g++-v3/i686-pc-linux-gnu/bits/os_defines.h" 1 3
# 37 "/usr/local/include/g++-v3/i686-pc-linux-gnu/bits/os_defines.h" 3
# 1 "/usr/include/features.h" 1 3
# 283 "/usr/include/features.h" 3
# 1 "/usr/include/sys/cdefs.h" 1 3
# 284 "/usr/include/features.h" 2 3
# 311 "/usr/include/features.h" 3
# 1 "/usr/include/gnu/stubs.h" 1 3
# 312 "/usr/include/features.h" 2 3
# 38 "/usr/local/include/g++-v3/i686-pc-linux-gnu/bits/os_defines.h" 2 3
# 35 "/usr/local/include/g++-v3/i686-pc-linux-gnu/bits/c++config.h" 2 3
# 40 "/usr/local/include/g++-v3/bits/std_cstring.h" 2 3
# 1 "/usr/local/include/g++-v3/bits/std_cstddef.h" 1 3
# 40 "/usr/local/include/g++-v3/bits/std_cstddef.h" 3
# 1 "/usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.1/include/stddef.h" 1 3
# 147 "/usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.1/include/stddef.h" 3
typedef int ptrdiff_t;
# 199 "/usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.1/include/stddef.h" 3
typedef unsigned int size_t;
# 41 "/usr/local/include/g++-v3/bits/std_cstddef.h" 2 3

namespace std
{
  using ::ptrdiff_t;
  using ::size_t;
}
# 41 "/usr/local/include/g++-v3/bits/std_cstring.h" 2 3
# 43 "/usr/local/include/g++-v3/bits/std_cstring.h" 3
# 1 "/usr/include/string.h" 1 3
# 26 "/usr/include/string.h" 3
# 1 "/usr/include/features.h" 1 3
# 27 "/usr/include/string.h" 2 3

extern "C" {




# 1 "/usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.1/include/stddef.h" 1 3
# 34 "/usr/include/string.h" 2 3



extern void *memcpy (void *__restrict __dest,
                     __const void *__restrict __src, size_t __n) throw ();


extern void *memmove (void *__dest, __const void *__src, size_t __n)
     throw ();





extern void *memccpy (void *__restrict __dest, __const void *__restrict __src,
                      int __c, size_t __n)
     throw ();




extern void *memset (void *__s, int __c, size_t __n) throw ();


extern int memcmp (__const void *__s1, __const void *__s2, size_t __n)
     throw () __attribute__ ((__pure__));


extern void *memchr (__const void *__s, int __c, size_t __n)
      throw () __attribute__ ((__pure__));




extern void *rawmemchr (__const void *__s, int __c) throw () __attribute__ ((__pure__));


extern void *memrchr (__const void *__s, int __c, size_t __n)
      throw () __attribute__ ((__pure__));




extern char *strcpy (char *__restrict __dest, __const char *__restrict __src)
     throw ();

extern char *strncpy (char *__restrict __dest,
                      __const char *__restrict __src, size_t __n) throw ();


extern char *strcat (char *__restrict __dest, __const char *__restrict __src)
     throw ();

extern char *strncat (char *__restrict __dest, __const char *__restrict __src,
                      size_t __n) throw ();


extern int strcmp (__const char *__s1, __const char *__s2)
     throw () __attribute__ ((__pure__));

extern int strncmp (__const char *__s1, __const char *__s2, size_t __n)
     throw () __attribute__ ((__pure__));


extern int strcoll (__const char *__s1, __const char *__s2)
     throw () __attribute__ ((__pure__));

extern size_t strxfrm (char *__restrict __dest,
                       __const char *__restrict __src, size_t __n) throw ();





# 1 "/usr/include/xlocale.h" 1 3
# 28 "/usr/include/xlocale.h" 3
typedef struct __locale_struct
{

  struct locale_data *__locales[13];


  const unsigned short int *__ctype_b;
  const int *__ctype_tolower;
  const int *__ctype_toupper;
} *__locale_t;
# 109 "/usr/include/string.h" 2 3


extern int __strcoll_l (__const char *__s1, __const char *__s2, __locale_t __l)
     throw () __attribute__ ((__pure__));

extern size_t __strxfrm_l (char *__dest, __const char *__src, size_t __n,
                           __locale_t __l) throw ();




extern char *strdup (__const char *__s) throw () __attribute__ ((__malloc__));






extern char *strndup (__const char *__string, size_t __n)
     throw () __attribute__ ((__malloc__));
# 155 "/usr/include/string.h" 3
extern char *strchr (__const char *__s, int __c) throw () __attribute__ ((__pure__));

extern char *strrchr (__const char *__s, int __c) throw () __attribute__ ((__pure__));




extern char *strchrnul (__const char *__s, int __c) throw () __attribute__ ((__pure__));




extern size_t strcspn (__const char *__s, __const char *__reject)
     throw () __attribute__ ((__pure__));


extern size_t strspn (__const char *__s, __const char *__accept)
     throw () __attribute__ ((__pure__));

extern char *strpbrk (__const char *__s, __const char *__accept)
     throw () __attribute__ ((__pure__));

extern char *strstr (__const char *__haystack, __const char *__needle)
     throw () __attribute__ ((__pure__));



extern char *strcasestr (__const char *__haystack, __const char *__needle)
     throw () __attribute__ ((__pure__));



extern char *strtok (char *__restrict __s, __const char *__restrict __delim)
     throw ();



extern char *__strtok_r (char *__restrict __s,
                         __const char *__restrict __delim,
                         char **__restrict __save_ptr) throw ();

extern char *strtok_r (char *__restrict __s, __const char *__restrict __delim,
                       char **__restrict __save_ptr) throw ();






extern void *memmem (__const void *__haystack, size_t __haystacklen,
                     __const void *__needle, size_t __needlelen)
     throw () __attribute__ ((__pure__));



extern void *__mempcpy (void *__restrict __dest,
                        __const void *__restrict __src, size_t __n) throw ();
extern void *mempcpy (void *__restrict __dest,
                      __const void *__restrict __src, size_t __n) throw ();




extern size_t strlen (__const char *__s) throw () __attribute__ ((__pure__));




extern size_t strnlen (__const char *__string, size_t __maxlen)
     throw () __attribute__ ((__pure__));




extern char *strerror (int __errnum) throw ();



extern char *__strerror_r (int __errnum, char *__buf, size_t __buflen) throw ();
extern char *strerror_r (int __errnum, char *__buf, size_t __buflen) throw ();




extern void __bzero (void *__s, size_t __n) throw ();



extern void bcopy (__const void *__src, void *__dest, size_t __n) throw ();


extern void bzero (void *__s, size_t __n) throw ();


extern int bcmp (__const void *__s1, __const void *__s2, size_t __n)
     throw () __attribute__ ((__pure__));


extern char *index (__const char *__s, int __c) throw () __attribute__ ((__pure__));


extern char *rindex (__const char *__s, int __c) throw () __attribute__ ((__pure__));



extern int __ffs (int __i) throw () __attribute__ ((const));
extern int ffs (int __i) throw () __attribute__ ((const));




extern int ffsl (long int __l) throw () __attribute__ ((const));

__extension__ extern int ffsll (long long int __ll)
     throw () __attribute__ ((const));




extern int strcasecmp (__const char *__s1, __const char *__s2)
     throw () __attribute__ ((__pure__));


extern int strncasecmp (__const char *__s1, __const char *__s2, size_t __n)
     throw () __attribute__ ((__pure__));





extern int __strcasecmp_l (__const char *__s1, __const char *__s2,
                           __locale_t __loc) throw () __attribute__ ((__pure__));

extern int __strncasecmp_l (__const char *__s1, __const char *__s2,
                            size_t __n, __locale_t __loc)
     throw () __attribute__ ((__pure__));





extern char *strsep (char **__restrict __stringp,
                     __const char *__restrict __delim) throw ();




extern int strverscmp (__const char *__s1, __const char *__s2)
     throw () __attribute__ ((__pure__));


extern char *strsignal (int __sig) throw ();


extern char *__stpcpy (char *__restrict __dest, __const char *__restrict __src)
     throw ();
extern char *stpcpy (char *__restrict __dest, __const char *__restrict __src)
     throw ();



extern char *__stpncpy (char *__restrict __dest,
                        __const char *__restrict __src, size_t __n) throw ();
extern char *stpncpy (char *__restrict __dest,
                      __const char *__restrict __src, size_t __n) throw ();


extern char *strfry (char *__string) throw ();


extern void *memfrob (void *__s, size_t __n) throw ();






extern char *basename (__const char *__filename) throw ();
# 365 "/usr/include/string.h" 3
}
# 44 "/usr/local/include/g++-v3/bits/std_cstring.h" 2 3
# 69 "/usr/local/include/g++-v3/bits/std_cstring.h" 3
namespace std
{
  extern "C" void* memcpy(void*, const void*, size_t);
  extern "C" void* memmove(void*, const void*, size_t);
  extern "C" char* strcpy(char*, const char*);
  extern "C" char* strncpy(char*, const char*, size_t);
  extern "C" char* strcat(char*, const char*);
  extern "C" char* strncat(char*, const char*, size_t);
  extern "C" int memcmp(const void*, const void*, size_t);
  extern "C" int strcmp(const char*, const char*);
  extern "C" int strcoll(const char*, const char*);
  extern "C" int strncmp(const char*, const char*, size_t);
  extern "C" size_t strxfrm(char*, const char*, size_t);
  extern "C" const void* memchr(const void*, int, size_t);
  inline void*
  memchr(void* __p, int __c, size_t __n)
  {
    return const_cast<void*>(memchr(const_cast<const void*>(__p), __c, __n));
  }
  extern "C" const char* strchr(const char*, int);
  inline char*
  strchr(char* __s1, int __n)
  {
    return const_cast<char*>(strchr(const_cast<const char*>(__s1), __n));
  }
  extern "C" size_t strcspn(const char*, const char*);
  extern "C" const char* strpbrk(const char*, const char*);
  inline char*
  strpbrk(char* __s1, const char* __s2)
  {
    return const_cast<char*>(strpbrk(const_cast<const char*>(__s1), __s2));
  }
  extern "C" const char* strrchr(const char*, int);
  inline char*
  strrchr(char* __s1, int __n)
  {
    return const_cast<char*>(strrchr(const_cast<const char*>(__s1), __n));
  }
  extern "C" size_t strspn(const char*, const char*);
  extern "C" const char* strstr(const char*, const char*);
  inline char*
  strstr(char* __s1, const char* __s2)
  {
    return const_cast<char*>(strstr(const_cast<const char*>(__s1), __s2));
  }
  extern "C" char* strtok(char*, const char*);
  extern "C" void* memset(void*, int, size_t);
  extern "C" char* strerror(int);
  extern "C" size_t strlen(const char*);
}
# 3 "/usr/local/include/g++-v3/cstring" 2 3
# 2 "td.C" 2
using namespace std;

void f(const char *name)
{
    strchr(name,'/');
}

>Fix:
	
>Release-Note:
>Audit-Trail:
>Unformatted:


             reply	other threads:[~2001-05-07 12:36 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-05-07 12:36 Peter Schmid [this message]
2001-06-09 23:51 bkoz

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=200105072027.WAA02032@snake.iap.physik.tu-darmstadt.de \
    --to=schmid@snake.iap.physik.tu-darmstadt.de \
    --cc=gcc-gnats@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).