File: bug-strspn1.c

package info (click to toggle)
glibc 2.40-5
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 292,840 kB
  • sloc: ansic: 1,038,938; asm: 239,498; makefile: 19,481; python: 13,369; sh: 11,472; cpp: 5,147; awk: 1,723; perl: 317; yacc: 292; pascal: 182; sed: 19
file content (26 lines) | stat: -rw-r--r-- 627 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
#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 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");
  strspn (b++, "");
  DIAG_POP_NEEDS_COMMENT;
  if (b != a + 1)
    return 1;

  return 0;
}