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]
Other format: [Raw text]

[Bug libgcc/71282] C,C++ function strpbrk arg 1 has wrong type on Raspian 4.1.19


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=71282

Martin Sebor <msebor at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
                 CC|                            |msebor at gcc dot gnu.org
         Resolution|---                         |INVALID

--- Comment #1 from Martin Sebor <msebor at gcc dot gnu.org> ---
Unlike in C, in C++ there are two overloads of strpbrk (declared by GLIBC on
GNU/Linux):

  const char* strpbrk (const char*, const char*);

and

  char* strpbrk (char*, const char*);

The first one is used when the first argument is a const pointer and array, as
in the test case, and the second one otherwise.  Since the first one returns a
const char* which is not convertible to char*, the program is incorrect.

Unfortunately, the caret in the error makes this hard to see.  Current trunk
does only slightly better:

error: invalid conversion from âconst char*â to âchar*â [-fpermissive]
     char *pSpc = strpbrk(tstStr, " ");
                  ~~~~~~~^~~~~~~~~~~~~

That might be worth raising a separate bug for (if one doesn't already exist),
but this one is invalid.

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