Files
glibc/string/bug-strspn1.c
T

28 lines
682 B
C
Raw Normal View History

2000-10-30 04:08:58 +00:00
/* Test case by Joseph S. Myers <jsm28@cam.ac.uk>. */
2000-10-31 04:38:55 +00:00
#undef __USE_STRING_INLINES
2000-10-30 04:08:58 +00:00
#define __USE_STRING_INLINES
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#include <libc-diag.h>
2000-10-30 04:08:58 +00:00
int
main (void)
{
const char *a = "abc";
const char *b = a;
DIAG_PUSH_NEEDS_COMMENT;
/* GCC 9 correctly warns that this call to strspn is useless. That
is deliberate; this test is verifying that a side effect in an
argument still occurs when the call itself is useless and could
be optimized to return a constant. */
DIAG_IGNORE_NEEDS_COMMENT (9, "-Wunused-value");
2000-10-30 04:08:58 +00:00
strspn (b++, "");
DIAG_POP_NEEDS_COMMENT;
2000-10-30 04:08:58 +00:00
if (b != a + 1)
return 1;
2000-10-30 04:08:58 +00:00
return 0;
2000-10-30 04:08:58 +00:00
}