On 10/05/2018 12:54 PM, David Edelsohn wrote:
memchr-1.c tests for char (test_narrow) and wchar (test_wide). The
wide character test assumes 32 bit wide character, while 32 bit AIX
uses 16 bit wide character. This assumption causes the wide character
part of the test to fail in 32 bit mode on AIX (it succeeds on 64 bit
AIX).
The testcase already includes ifdefs for endianness. The "narrow"
part of the test succeeds and is a useful test on AIX. Me proposed
solution adds an AIX-specific ifdef in the testcase to avoid the
compile-time errors in 32 bit mode.
Because of the structure of the testcase, I need to #ifdef test_wide()
and its constants, and separately it's invocation in main(), as
opposed to making test_wide() a no-op that is called.
Another alternative is to split memchr-1.c into memchr-1.c for
test_narrow and memchr-2.c for test_wide, with the latter skipped on
AIX using a DejaGNU directive.
Is the #ifdef okay or would others prefer that I split the testcase?
No solution is particularly elegant.
That's my bad for hardwiring 4 as the wchar_t size. Sorry about
the breakage. I can't think of any better solutions than what
you covered above. It would be nice to exercise this optimization
with 16-bit wchar_t. It looks like GCC has a -fshort-wchar option
to force wchar_t to be 2 bytes wide that I didn't know about.
That will make the problem easier to solve without necessarily
having to build all of GCC on AIX. Let me take care of it.
Martin
Thanks, David
* gcc.c-torture/execute/memchr-1.c (test_wide): Skip on 32 bit AIX.
Index: memchr-1.c
===================================================================
--- memchr-1.c (revision 264869)
+++ memchr-1.c (working copy)
@@ -106,6 +106,7 @@
A (memchr (&s5_3[1][i0], 0, sizeof s5_3[1] - i0) == &s5_3[1][4]);
}
+#if !defined(_AIX) || defined(__64BIT__)
static const wchar_t wc = L'1';
static const wchar_t ws1[] = L"1";
static const wchar_t ws4[] = L"\x00123456\x12005678\x12340078\x12345600";
@@ -144,10 +145,13 @@
A (memchr (&ws4[3], 0, nb - 3 * nwb) == pws4 + 3 * nwb + 3);
#endif
}
+#endif
int main ()
{
test_narrow ();
+#if !defined(_AIX) || defined(__64BIT__)
test_wide ();
+#endif
}