Is this a programming error, or a compiler error..
Willem Jan Withagen
wjw at digiware.nl
Wed Mar 13 11:57:45 UTC 2019
Hi,
I'm getting a crash in a Ceph test program in the following pice of code:
struct entity_addrvec_t {
vector<entity_addr_t> v;
.....
entity_addr_t legacy_addr() const {
for (auto& a : v) {
if (a.type == entity_addr_t::TYPE_LEGACY) {
return a;
}
}
return entity_addr_t();
}
......
Where the loop is taken, even if v.size() == 0
So v content is pointing to random memory and itterating over the next
pointer results in a crash.
I would expect the loop not to be executed....
--WjW
More information about the freebsd-toolchain
mailing list