bug-strpbrk1.c 684 B

123456789101112131415161718192021222324252627
  1. /* Test case by Joseph S. Myers <jsm28@cam.ac.uk>. */
  2. #undef __USE_STRING_INLINES
  3. #define __USE_STRING_INLINES
  4. #include <string.h>
  5. #include <stdlib.h>
  6. #include <stdio.h>
  7. #include <libc-diag.h>
  8. int
  9. main (void)
  10. {
  11. const char *a = "abc";
  12. const char *b = a;
  13. DIAG_PUSH_NEEDS_COMMENT;
  14. /* GCC 9 correctly warns that this call to strpbrk is useless. That
  15. is deliberate; this test is verifying that a side effect in an
  16. argument still occurs when the call itself is useless and could
  17. be optimized to return a constant. */
  18. DIAG_IGNORE_NEEDS_COMMENT (9, "-Wunused-value");
  19. strpbrk (b++, "");
  20. DIAG_POP_NEEDS_COMMENT;
  21. if (b != a + 1)
  22. return 1;
  23. return 0;
  24. }