llvm / llvm-project

The LLVM Project is a collection of modular and reusable compiler and toolchain technologies.
http://llvm.org
Other
28.32k stars 11.69k forks source link

False positive: std::valarray standard conforming operator[] triggers null reference warning #21716

Open llvmbot opened 9 years ago

llvmbot commented 9 years ago
Bugzilla Link 21342
Version unspecified
OS Linux
Reporter LLVM Bugzilla Contributor
CC @zygoloid

Extended Description

libcxx/include/valarray:841:53: warning: Returning null reference value_type& operator[](sizet i) {return begin[__i];} ^~~~~~~~ Standard says: N3797 clause: 26.6.2.4 valarray element access

paragraph 6.) If the subscript operator is invoked with a size_t argument whose value is not less than the length of the array, the behavior is undefined.

llvmbot commented 9 years ago

sorry, disregard the last entry, I have another bug queued up and mistakenly provided those repro steps.

For this bug std::valarray: navigate to: /libcxx/test/numerics/numarray/template.valarray/valarray.cons

scan-build -k -analyze-headers clang++ -std=c++1y -stdlib=libc++ -g3 -O0 -I//libcxx/include copy.pass.cpp

llvmbot commented 9 years ago

to repro, navigate to /libcxx/test/numerics/rand/rand.dis/rand.dist.bern

scan-build -k -analyze-headers clang++ -std=c++1y -stdlib=libc++ -g3 -O0 -I//libcxx/include eval_param.pass.cpp

ec04fc15-fa35-46f2-80e1-5d271f2ef708 commented 9 years ago

Please provide more context and/or steps to reproduce.

llvmbot commented 9 years ago

assigned to @tkremenek