Open Quuxplusone opened 4 years ago
-- The C compiler identification is GNU 9.2.0
-- The CXX compiler identification is GNU 9.2.0
On the linux builder.
Looks like a false positive warning to me - but you'd have to reduce it further to prove that before filing a bug with GCC if you wanted to.
But incrementing a pointer to a single object isn't UB - you can have a pointer to "one past" an object.
Actually, the code in SmallVector.h looks suspicious to me. It's attempting to
allow something like "vec.insert(vec.begin(), *vec.begin())", but I'm pretty
sure it doesn't work right: it isn't correctly taking into account the
possibility of the vector growing.
I'm not sure that's related to the warning, though; if it were truly detecting
that issue, it would probably print a different warning.
(In reply to Eli Friedman from comment #3)
> Actually, the code in SmallVector.h looks suspicious to me. It's attempting
> to allow something like "vec.insert(vec.begin(), *vec.begin())", but I'm
> pretty sure it doesn't work right: it isn't correctly taking into account
> the possibility of the vector growing.
Oh, yeah - I think I went down that rabbit hole a few years ago & eventually
gave up thinking about what scenarios it should/could support. I should've
written some notes. But I'm pretty sure it claims to make some things work that
don't work.
> I'm not sure that's related to the warning, though; if it were truly
> detecting that issue, it would probably print a different warning.
Yeah - pretty sure it isn't, but could be wrong.
While compiling the 10.0.0rc1 on our nix builder: