Quuxplusone / LLVMBugzillaTest

0 stars 0 forks source link

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

Open Quuxplusone opened 9 years ago

Quuxplusone commented 9 years ago
Bugzilla Link PR21342
Status NEW
Importance P normal
Reported by Stephen MacKenzie (stevemac321@live.com)
Reported on 2014-10-22 14:40:36 -0700
Last modified on 2014-10-22 15:56:16 -0700
Version unspecified
Hardware PC Linux
CC llvm-bugs@lists.llvm.org, richard-llvm@metafoo.co.uk
Fixed by commit(s)
Attachments
Blocks
Blocked by
See also
libcxx/include/valarray:841:53: warning: Returning null reference
    value_type&       operator[](size_t __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.
Quuxplusone commented 9 years ago

Please provide more context and/or steps to reproduce.

Quuxplusone 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/<yourpath>/libcxx/include eval_param.pass.cpp
Quuxplusone 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/<yourpath>/libcxx/include copy.pass.cpp