bug-strspn1.c 627 B

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