File: bug-strpbrk1.c

package info (click to toggle)
glibc 2.28-10%2Bdeb10u1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 272,660 kB
  • sloc: ansic: 1,008,227; asm: 259,607; makefile: 11,278; sh: 10,460; python: 6,910; cpp: 4,995; perl: 2,258; awk: 2,005; yacc: 290; pascal: 182; sed: 73
file content (27 lines) | stat: -rw-r--r-- 684 bytes parent folder | download | duplicates (12)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
/* Test case by Joseph S. Myers <jsm28@cam.ac.uk>.  */
#undef __USE_STRING_INLINES
#define __USE_STRING_INLINES
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#include <libc-diag.h>

int
main (void)
{
  const char *a = "abc";
  const char *b = a;

  DIAG_PUSH_NEEDS_COMMENT;
  /* GCC 9 correctly warns that this call to strpbrk 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");
  strpbrk (b++, "");
  DIAG_POP_NEEDS_COMMENT;
  if (b != a + 1)
    return 1;

  return 0;
}