Blame string/bug-strspn1.c

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