This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug libgcc/71282] C,C++ function strpbrk arg 1 has wrong type on Raspian 4.1.19
- From: "msebor at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Thu, 26 May 2016 03:15:54 +0000
- Subject: [Bug libgcc/71282] C,C++ function strpbrk arg 1 has wrong type on Raspian 4.1.19
- Auto-submitted: auto-generated
- References: <bug-71282-4 at http dot gcc dot gnu dot org/bugzilla/>
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.