On 2/13/24 05:27, Rainer Orth wrote:
Hi Jason,
On 2/2/24 10:23, Rainer Orth wrote:
c-c++-common/pr103798-2.c FAILs on Solaris when compiled as C++:
FAIL: c-c++-common/pr103798-2.c -std=gnu++14 scan-assembler-not memchr
FAIL: c-c++-common/pr103798-2.c -std=gnu++17 scan-assembler-not memchr
FAIL: c-c++-common/pr103798-2.c -std=gnu++20 scan-assembler-not memchr
FAIL: c-c++-common/pr103798-2.c -std=gnu++98 scan-assembler-not memchr
As H.J. analyzed in the PR, Solaris <string.h> declares std::memchr, not
memchr, which isn't treated as __builtin_memchr.
The problem seems to be not the std::, but that the Solaris string.h
declares
const void *memchr(const void *, int, size_t);
as specified by the C++ standard, while gcc expects the return type to be
void* like in C.
This looks like a GCC bug, not Solaris; I'd prefer to xfail the testcase
rather than work around the compiler bug.
thanks for the analysis.
What I found with my current patch, just the memchr prototype changed to
always return const void *, the test still PASSes as C, but FAILs as
C++.
In the C++ case I get a warning:
/vol/gcc/src/hg/master/local/gcc/testsuite/c-c++-common/pr103798-2.c:10:20:
warning: declaration of ‘const void* memchr(const void*, int, size_t)’
conflicts with built-in declaration ‘void* memchr(const void*, int, unsigned
int)’ [-Wbuiltin-declaration-mismatch]
Here's the patch to xfail the test instead.
Tested on sparc-sun-solaris2.11 and x86_64-pc-linux-gnu.
Ok for trunk?
OK, thanks.
Jason