* [PATCH] testsuite: Fix c-c++-common/pr103798-2.c on Solaris [PR113706]
@ 2024-02-02 15:23 Rainer Orth
2024-02-12 21:24 ` Jason Merrill
0 siblings, 1 reply; 4+ messages in thread
From: Rainer Orth @ 2024-02-02 15:23 UTC (permalink / raw)
To: gcc-patches; +Cc: H.J. Lu
[-- Attachment #1: Type: text/plain, Size: 1020 bytes --]
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.
To avoid this, this patch declares memchr directly instead of including
<string.h>.
Tested on i386-pc-solaris2.11, sparc-sun-solaris2.11, and
i686-pc-linux-gnu.
Ok for trunk?
Rainer
--
-----------------------------------------------------------------------------
Rainer Orth, Center for Biotechnology, Bielefeld University
2024-02-01 Rainer Orth <ro@CeBiTec.Uni-Bielefeld.DE>
gcc/testsuite:
PR tree-optimization/113706
* c-c++-common/pr103798-2.c (NULL): Define.
(size_t, memchr): Declare instead of including <string.h>.
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: sol2-testsuite-pr103798-2.patch --]
[-- Type: text/x-patch, Size: 660 bytes --]
# HG changeset patch
# Parent 943813561aef290adb442042f9c4fe9999cd82ee
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
@@ -1,7 +1,16 @@
/* { dg-do run } */
/* { dg-options "-O2 -fdump-tree-optimized -save-temps" } */
-#include <string.h>
+#define NULL ((void *) 0)
+
+typedef __SIZE_TYPE__ size_t;
+#ifdef __cplusplus
+extern "C" {
+#endif
+extern void *memchr (const void *, int, size_t);
+#ifdef __cplusplus
+}
+#endif
__attribute__ ((weak))
int
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] testsuite: Fix c-c++-common/pr103798-2.c on Solaris [PR113706]
2024-02-02 15:23 [PATCH] testsuite: Fix c-c++-common/pr103798-2.c on Solaris [PR113706] Rainer Orth
@ 2024-02-12 21:24 ` Jason Merrill
2024-02-13 10:27 ` Rainer Orth
0 siblings, 1 reply; 4+ messages in thread
From: Jason Merrill @ 2024-02-12 21:24 UTC (permalink / raw)
To: Rainer Orth, gcc-patches; +Cc: H.J. Lu
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.
Jason
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] testsuite: Fix c-c++-common/pr103798-2.c on Solaris [PR113706]
2024-02-12 21:24 ` Jason Merrill
@ 2024-02-13 10:27 ` Rainer Orth
2024-02-13 20:04 ` Jason Merrill
0 siblings, 1 reply; 4+ messages in thread
From: Rainer Orth @ 2024-02-13 10:27 UTC (permalink / raw)
To: Jason Merrill; +Cc: gcc-patches, H.J. Lu
[-- Attachment #1: Type: text/plain, Size: 1884 bytes --]
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 <ro@CeBiTec.Uni-Bielefeld.DE>
testsuite:
PR tree-optimization/113706
* c-c++-common/pr103798-2.c (scan-assembler-not): xfail for C++ on
Solaris.
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: sol2-testsuite-pr103798-2.patch --]
[-- Type: text/x-patch, Size: 560 bytes --]
# 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* } } } } */
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] testsuite: Fix c-c++-common/pr103798-2.c on Solaris [PR113706]
2024-02-13 10:27 ` Rainer Orth
@ 2024-02-13 20:04 ` Jason Merrill
0 siblings, 0 replies; 4+ messages in thread
From: Jason Merrill @ 2024-02-13 20:04 UTC (permalink / raw)
To: Rainer Orth; +Cc: gcc-patches, H.J. Lu
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
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2024-02-13 20:05 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-02-02 15:23 [PATCH] testsuite: Fix c-c++-common/pr103798-2.c on Solaris [PR113706] Rainer Orth
2024-02-12 21:24 ` Jason Merrill
2024-02-13 10:27 ` Rainer Orth
2024-02-13 20:04 ` Jason Merrill
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).