This error is diagnosed using valgrind using the (default) memcheck , generating a series of warnings, including:
$ valgrind ./unin … ==12185== Use of uninitialised value of size 8 ==12185== at 0x4F39BC3: ??? (in /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.21) ==12185== by 0x4F3AD89: std::ostreambuf_iterator<char, std::char_traits<char> > std::num_put<char, std::ostreambuf_iterator<char, std::char_traits<char> > >::_M_insert_int<long>(std::ostreambuf_iterator<char, std::char_traits<char> >, std::ios_base&, char, long) const (in /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.21) ==12185== by 0x4F3AF8C: std::num_put<char, std::ostreambuf_iterator<char, std::char_traits<char> > >::do_put(std::ostreambuf_iterator<char, std::char_traits<char> >, std::ios_base&, char, long) const (in /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.21) ==12185== by 0x4F474E9: std::ostream& std::ostream::_M_insert<long>(long) (in /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.21) ==12185== by 0x400763: main (in [censored]/unin)
It must also be found with Clang's location disinfectant. However, I understand that you are most interested in checking compile time. In the end, existing test suites can never execute any code, and catching an error is always better before. You can use GCC 5.1 (even if you used it only for this purpose), or you can use a dedicated static analyzer. Fortunately, clang comes with a static analyzer called as scan-build (included at least in Debian / Ubuntu packages):
$ scan-build clang -c unin.cxx scan-build: Using '/usr/lib/llvm-3.6/bin/clang' for static analysis unin.cxx:10:3: warning: Function call argument is an uninitialized value std::cout << ax; ^~~~~~~~~~~~~~~~ 1 warning generated. scan-build: 1 bug found.
source share