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? Rainer -- ----------------------------------------------------------------------------- Rainer Orth, Center for Biotechnology, Bielefeld University 2024-02-12 Rainer Orth <r...@cebitec.uni-bielefeld.de> testsuite: PR tree-optimization/113706 * c-c++-common/pr103798-2.c (scan-assembler-not): xfail for C++ on Solaris.
# HG changeset patch # Parent 1409f56e818a7240dd65da9566400f308a996beb testsuite: Fix c-c++-common/pr103798-2.c on Solaris [PR113706] diff --git a/gcc/testsuite/c-c++-common/pr103798-2.c b/gcc/testsuite/c-c++-common/pr103798-2.c --- a/gcc/testsuite/c-c++-common/pr103798-2.c +++ b/gcc/testsuite/c-c++-common/pr103798-2.c @@ -27,4 +27,5 @@ main () return 0; } -/* { dg-final { scan-assembler-not "memchr" } } */ +/* See PR tree-optimization/113706 for the xfail. */ +/* { dg-final { scan-assembler-not "memchr" { xfail { c++ && *-*-solaris2* } } } } */