[Bug libgcc/71282] New: C,C++ function strpbrk arg 1 has wrong type on Raspian 4.1.19
rayconnell at usa dot net
gcc-bugzilla@gcc.gnu.org
Wed May 25 19:50:00 GMT 2016
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=71282
Bug ID: 71282
Summary: C,C++ function strpbrk arg 1 has wrong type on Raspian
4.1.19
Product: gcc
Version: 4.9.2
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: libgcc
Assignee: unassigned at gcc dot gnu.org
Reporter: rayconnell at usa dot net
Target Milestone: ---
Compiling this code with gcc (Raspbian 4.9.2-10):
#include <stdio.h>
#include <string.h>
const char *tstStr = "Some test data";
int main(void){
char *pSpc = strpbrk(tstStr, " ");
printf(pSpc);
return 0;
}
causes GCC to emit the following error:
Building file: test_strpbrk.cpp
Invoking: G++ Compiler
g++ -O3 -Wall -c -fmessage-length=0 -MMD -MP -MF"test_strpbrk.d"
-MT"test_strpbrk.d" -o "test_strpbrk.o" "test_strpbrk.cpp"
test_strpbrk.cpp: In function ‘int main()’:
test_strpbrk.cpp:7:37: error: invalid conversion from ‘const char*’ to ‘char*’
[-fpermissive]
char *pSpc = strpbrk(tstStr, " ");
^
subdir.mk:11: recipe for target 'test_strpbrk.o' failed
make: *** [test_strpbrk.o] Error 1
However, casting the tstStr var as (char *) causes the program to compile. But
the first arg of strpbrk() should accept const char * and not require char *.
More information about the Gcc-bugs
mailing list