Bug Summary

File:conftest.cpp
Warning:line 173, column 8
Value stored to 'c' during its initialization is never read

Annotated Source Code

Press '?' to see keyboard shortcuts

clang -cc1 -cc1 -triple x86_64-pc-linux-gnu -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name conftest.cpp -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=cplusplus -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model pic -pic-level 2 -pic-is-pie -mframe-pointer=none -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fcoverage-compilation-dir=/tmp/build/hfst-ospell/hfst-ospell-0.5.4+g383~85edd77e -resource-dir /usr/lib/llvm-16/lib/clang/16 -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/14/../../../../include/c++/14 -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/14/../../../../include/x86_64-linux-gnu/c++/14 -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/14/../../../../include/c++/14/backward -internal-isystem /usr/lib/llvm-16/lib/clang/16/include -internal-isystem /usr/local/include -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/14/../../../../x86_64-linux-gnu/include -internal-externc-isystem /usr/include/x86_64-linux-gnu -internal-externc-isystem /include -internal-externc-isystem /usr/include -O2 -fdeprecated-macro -fdebug-compilation-dir=/tmp/build/hfst-ospell/hfst-ospell-0.5.4+g383~85edd77e -ferror-limit 19 -fgnuc-version=4.2.1 -fcxx-exceptions -fexceptions -vectorize-loops -vectorize-slp -analyzer-output=html -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /tmp/build/hfst-ospell/scan-build/2024-09-11-141236-96101-1 -x c++ conftest.cpp
1/* confdefs.h */
2#define PACKAGE_NAME"hfstospell" "hfstospell"
3#define PACKAGE_TARNAME"hfstospell" "hfstospell"
4#define PACKAGE_VERSION"0.5.4" "0.5.4"
5#define PACKAGE_STRING"hfstospell 0.5.4" "hfstospell 0.5.4"
6#define PACKAGE_BUGREPORT"hfst-bugs@helsinki.fi" "hfst-bugs@helsinki.fi"
7#define PACKAGE_URL"http://hfst.github.io" "http://hfst.github.io"
8#define PACKAGE"hfstospell" "hfstospell"
9#define VERSION"0.5.4" "0.5.4"
10#define ZHFST_EXTRACT_TO_MEM1 1
11/* end confdefs.h. */
12
13// Does the compiler advertise C++98 conformance?
14#if !defined __cplusplus201703L || __cplusplus201703L < 199711L
15# error "Compiler does not advertise C++98 conformance"
16#endif
17
18// These inclusions are to reject old compilers that
19// lack the unsuffixed header files.
20#include <cstdlib>
21#include <exception>
22
23// <cassert> and <cstring> are *not* freestanding headers in C++98.
24extern void assert (int);
25namespace std {
26 extern int strcmp (const char *, const char *);
27}
28
29// Namespaces, exceptions, and templates were all added after "C++ 2.0".
30using std::exception;
31using std::strcmp;
32
33namespace {
34
35void test_exception_syntax()
36{
37 try {
38 throw "test";
39 } catch (const char *s) {
40 // Extra parentheses suppress a warning when building autoconf itself,
41 // due to lint rules shared with more typical C programs.
42 assert (!(strcmp) (s, "test"));
43 }
44}
45
46template <typename T> struct test_template
47{
48 T const val;
49 explicit test_template(T t) : val(t) {}
50 template <typename U> T add(U u) { return static_cast<T>(u) + val; }
51};
52
53} // anonymous namespace
54
55
56// Does the compiler advertise C++ 2011 conformance?
57#if !defined __cplusplus201703L || __cplusplus201703L < 201103L
58# error "Compiler does not advertise C++11 conformance"
59#endif
60
61namespace cxx11test
62{
63 constexpr int get_val() { return 20; }
64
65 struct testinit
66 {
67 int i;
68 double d;
69 };
70
71 class delegate
72 {
73 public:
74 delegate(int n) : n(n) {}
75 delegate(): delegate(2354) {}
76
77 virtual int getval() { return this->n; };
78 protected:
79 int n;
80 };
81
82 class overridden : public delegate
83 {
84 public:
85 overridden(int n): delegate(n) {}
86 virtual int getval() override final { return this->n * 2; }
87 };
88
89 class nocopy
90 {
91 public:
92 nocopy(int i): i(i) {}
93 nocopy() = default;
94 nocopy(const nocopy&) = delete;
95 nocopy & operator=(const nocopy&) = delete;
96 private:
97 int i;
98 };
99
100 // for testing lambda expressions
101 template <typename Ret, typename Fn> Ret eval(Fn f, Ret v)
102 {
103 return f(v);
104 }
105
106 // for testing variadic templates and trailing return types
107 template <typename V> auto sum(V first) -> V
108 {
109 return first;
110 }
111 template <typename V, typename... Args> auto sum(V first, Args... rest) -> V
112 {
113 return first + sum(rest...);
114 }
115}
116
117
118int
119main (int argc, char **argv)
120{
121 int ok = 0;
122
123 assert (argc);
124 assert (! argv[0]);
125{
126 test_exception_syntax ();
127 test_template<double> tt (2.0);
128 assert (tt.add (4) == 6.0);
129 assert (true && !false);
130}
131
132
133{
134 // Test auto and decltype
135 auto a1 = 6538;
136 auto a2 = 48573953.4;
137 auto a3 = "String literal";
138
139 int total = 0;
140 for (auto i = a3; *i; ++i) { total += *i; }
141
142 decltype(a2) a4 = 34895.034;
143}
144{
145 // Test constexpr
146 short sa[cxx11test::get_val()] = { 0 };
147}
148{
149 // Test initializer lists
150 cxx11test::testinit il = { 4323, 435234.23544 };
151}
152{
153 // Test range-based for
154 int array[] = {9, 7, 13, 15, 4, 18, 12, 10, 5, 3,
155 14, 19, 17, 8, 6, 20, 16, 2, 11, 1};
156 for (auto &x : array) { x += 23; }
157}
158{
159 // Test lambda expressions
160 using cxx11test::eval;
161 assert (eval ([](int x) { return x*2; }, 21) == 42);
162 double d = 2.0;
163 assert (eval ([&](double x) { return d += x; }, 3.0) == 5.0);
164 assert (d == 5.0);
165 assert (eval ([=](double x) mutable { return d += x; }, 4.0) == 9.0);
166 assert (d == 5.0);
167}
168{
169 // Test use of variadic templates
170 using cxx11test::sum;
171 auto a = sum(1);
172 auto b = sum(1, 2);
173 auto c = sum(1.0, 2.0, 3.0);
Value stored to 'c' during its initialization is never read
174}
175{
176 // Test constructor delegation
177 cxx11test::delegate d1;
178 cxx11test::delegate d2();
179 cxx11test::delegate d3(45);
180}
181{
182 // Test override and final
183 cxx11test::overridden o1(55464);
184}
185{
186 // Test nullptr
187 char *c = nullptr;
188}
189{
190 // Test template brackets
191 test_template<::test_template<int>> v(test_template<int>(12));
192}
193{
194 // Unicode literals
195 char const *utf8 = u8"UTF-8 string \u2500";
196 char16_t const *utf16 = u"UTF-8 string \u2500";
197 char32_t const *utf32 = U"UTF-32 string \u2500";
198}
199
200 return ok;
201}
202