Open Flamefire opened 5 years ago
All checks with names started from clang-analyzer are implemented in Clang Static Analyzer, not Clang-tidy. Later just use them.
Sure:
clang-tidy-8 -p . -checks="-,clang-analyzer-core.CallAndMessage" main.cpp
1 warning generated.
/home/alex/Schreibtisch/cmakeTest/main.cpp:10:5: warning: 1st function call argument is an uninitialized value [clang-analyzer-core.CallAndMessage]
seed(seedVal);
^
/home/alex/Schreibtisch/cmakeTest/main.cpp:15:3: note: Calling 'MySeed
Input file:
extern void seed(unsigned);
template
int main(){ std::seed_seq seedSeq({1,2,3}); MySeed(seedSeq); }
Could you please provide full message with check name?
assigned to @devincoughlin
Extended Description
I implemented a custom PRNG according to the standard which uses a 32-Bit value as the seed. Hence I've implemented the
seed(seedSeq)
function as follows:{ unsigned seedVal; seedSeq.generate(&seedVal, (&seedVal) + 1); seed(seedVal); }
However clang-tidy warns about using an uninitialized value for the call to
seed
at the bottom.Relevant output:
[...] /usr/bin/../lib/gcc/x86_64-linux-gnu/8/../../../../include/c++/8/bits/random.tcc:3279:4: note: Value assigned to 'r1' r1 = detail::mod<_Type, [...] /usr/bin/../lib/gcc/x86_64-linux-gnu/8/../../../../include/c++/8/bits/random.tcc:3290:4: note: Uninitialized value stored to 'seedVal' begin[(k + p) % n] += __r1;
There is nothing else that looks suspicious. My guess is that as clang-tidy cannot deduce that
n = __end - __begin
in this case equals one it messes up the rest.