-fsanitize=nonnull-attribute failing on empty container

Jonathan Wakely jwakely.gcc@gmail.com
Thu May 28 18:06:00 GMT 2015


On 28 May 2015 at 18:26, Lars Gullik Bjønnes wrote:
> Is this is a known problem?

No, I don't think so.

At a guess, we're dispatching to memcmp for trivial types, but
shouldn't be doing that with null pointers.


> -------
> #include <vector>
>
> int main()
> {
>    std::vector<unsigned> a;
>    std::vector<unsigned> b;
>    return a == b;
> }
> ---------
>
> $ g++ -fsanitize=nonnull-attribute empty_vectors.cpp
> $ /a.out
> usr/include/c++/5.1.1/bits/stl_algobase.h:825:28: runtime error: null
> pointer passed as argument 1, which is declared to never be null
> /usr/include/c++/5.1.1/bits/stl_algobase.h:825:28: runtime error: null
> pointer passed as argument 2, which is declared to never be null
>
> $ g++ --version
> g++ (GCC) 5.1.1 20150422 (Red Hat 5.1.1-1)
> (fc22)
>
> I got the same with:
> $ /opt/gcc/gcc-5/bin/g++ --version
> g++ (GCC) 5.1.1
>
> --
>         Lgb



More information about the Gcc-help mailing list