Bug Summary

File:libs/opus-1.1-p2/conftest.c
Location:line 102, column 4
Description:Value stored to 'number' is never read

Annotated Source Code

1/* confdefs.h */
2#define PACKAGE_NAME"opus" "opus"
3#define PACKAGE_TARNAME"opus" "opus"
4#define PACKAGE_VERSION"1.1" "1.1"
5#define PACKAGE_STRING"opus 1.1" "opus 1.1"
6#define PACKAGE_BUGREPORT"opus@xiph.org" "opus@xiph.org"
7#define PACKAGE_URL"" ""
8#define STDC_HEADERS1 1
9#define HAVE_SYS_TYPES_H1 1
10#define HAVE_SYS_STAT_H1 1
11#define HAVE_STDLIB_H1 1
12#define HAVE_STRING_H1 1
13#define HAVE_MEMORY_H1 1
14#define HAVE_STRINGS_H1 1
15#define HAVE_INTTYPES_H1 1
16#define HAVE_STDINT_H1 1
17#define HAVE_UNISTD_H1 1
18#define HAVE_DLFCN_H1 1
19#define LT_OBJDIR".libs/" ".libs/"
20/* end confdefs.h. */
21#include <stdarg.h>
22#include <stdbool.h>
23#include <stdlib.h>
24#include <wchar.h>
25#include <stdio.h>
26
27// Check varargs macros. These examples are taken from C99 6.10.3.5.
28#define debug(...)fprintf (stderr, ...) fprintf (stderrstderr, __VA_ARGS__)
29#define showlist(...)puts ("...") puts (#__VA_ARGS__)
30#define report(test,...)((test) ? puts ("test") : printf (...)) ((test) ? puts (#test) : printf (__VA_ARGS__))
31static void
32test_varargs_macros (void)
33{
34 int x = 1234;
35 int y = 5678;
36 debug ("Flag")fprintf (stderr, "Flag");
37 debug ("X = %d\n", x)fprintf (stderr, "X = %d\n", x);
38 showlist (The first, second, and third items.)puts ("The first, second, and third items.");
39 report (x>y, "x is %d but y is %d", x, y)((x>y) ? puts ("x>y") : printf ("x is %d but y is %d", x
, y))
;
40}
41
42// Check long long types.
43#define BIG6418446744073709551615ull 18446744073709551615ull
44#define BIG324294967295ul 4294967295ul
45#define BIG_OK(18446744073709551615ull / 4294967295ul == 4294967297ull &&
18446744073709551615ull % 4294967295ul == 0)
(BIG6418446744073709551615ull / BIG324294967295ul == 4294967297ull && BIG6418446744073709551615ull % BIG324294967295ul == 0)
46#if !BIG_OK(18446744073709551615ull / 4294967295ul == 4294967297ull &&
18446744073709551615ull % 4294967295ul == 0)
47 your preprocessor is broken;
48#endif
49#if BIG_OK(18446744073709551615ull / 4294967295ul == 4294967297ull &&
18446744073709551615ull % 4294967295ul == 0)
50#else
51 your preprocessor is broken;
52#endif
53static long long int bignum = -9223372036854775807LL;
54static unsigned long long int ubignum = BIG6418446744073709551615ull;
55
56struct incomplete_array
57{
58 int datasize;
59 double data[];
60};
61
62struct named_init {
63 int number;
64 const wchar_t *name;
65 double average;
66};
67
68typedef const char *ccp;
69
70static inline int
71test_restrict (ccp restrict text)
72{
73 // See if C++-style comments work.
74 // Iterate through items via the restricted pointer.
75 // Also check for declarations in for loops.
76 for (unsigned int i = 0; *(text+i) != '\0'; ++i)
77 continue;
78 return 0;
79}
80
81// Check varargs and va_copy.
82static void
83test_varargs (const char *format, ...)
84{
85 va_list args;
86 va_start (args, format)__builtin_va_start(args, format);
87 va_list args_copy;
88 va_copy (args_copy, args)__builtin_va_copy(args_copy, args);
89
90 const char *str;
91 int number;
92 float fnumber;
93
94 while (*format)
95 {
96 switch (*format++)
97 {
98 case 's': // string
99 str = va_arg (args_copy, const char *)__builtin_va_arg(args_copy, const char *);
100 break;
101 case 'd': // int
102 number = va_arg (args_copy, int)__builtin_va_arg(args_copy, int);
Value stored to 'number' is never read
103 break;
104 case 'f': // float
105 fnumber = va_arg (args_copy, double)__builtin_va_arg(args_copy, double);
106 break;
107 default:
108 break;
109 }
110 }
111 va_end (args_copy)__builtin_va_end(args_copy);
112 va_end (args)__builtin_va_end(args);
113}
114
115int
116main ()
117{
118
119 // Check bool.
120 _Bool success = false0;
121
122 // Check restrict.
123 if (test_restrict ("String literal") == 0)
124 success = true1;
125 char *restrict newvar = "Another string";
126
127 // Check varargs.
128 test_varargs ("s, d' f .", "string", 65, 34.234);
129 test_varargs_macros ();
130
131 // Check flexible array members.
132 struct incomplete_array *ia =
133 malloc (sizeof (struct incomplete_array) + (sizeof (double) * 10));
134 ia->datasize = 10;
135 for (int i = 0; i < ia->datasize; ++i)
136 ia->data[i] = i * 1.234;
137
138 // Check named initializers.
139 struct named_init ni = {
140 .number = 34,
141 .name = L"Test wide string",
142 .average = 543.34343,
143 };
144
145 ni.number = 58;
146
147 int dynamic_array[ni.number];
148 dynamic_array[ni.number - 1] = 543;
149
150 // work around unused variable warnings
151 return (!success || bignum == 0LL || ubignum == 0uLL || newvar[0] == 'x'
152 || dynamic_array[ni.number - 1] != 543);
153
154 ;
155 return 0;
156}