Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Suppress false positive warning Recent versions of GCC are getting smarter, but here it has outsmarted itself. Drop the compiler a hint that 'possible null pointer dereference' is in fact impossible in this case. * Do not "fix up" iterator ordering Recent versions of GCC started printing a warning about those lines [1]: if (begin < end) { return input_buffer(&*begin, end - begin); } It says that we are "assuming pointer wraparound does not occur when comparing P +- C1 with P +- C2". In fact, we do assume that. [1]: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=49283 Here we try to be "helpful" and correct a possible mistake of swapping begin and end iterators. However, after thinking about it, this mistake is unlikely to happen. Moreover, we really rely on the user to provide correct iterators: 1) They should point into the same container. 2) They should point to valid elements of said container. 3) The container must store its elements in contiguous memory. 4) The "begin" iterator should come before the "end" one. If any of these assumptions is broken, you get undefined behavior (most likely resuling in a crash caused by segmentation fault). We cannot verify these assumptions by simply checking that one address is lower than the other. Debug builds of STL may check that, but that's as good as you can get it in C++. So stop doing that (un)helpful fixup. Remove the check and do not swap iterators, removing the cause of the warning too. * Initialize structs with memset() manually In C, it is perfectly legal to zero-initialize structures with {0}, like this: struct themis_scell_pbkdf2_context kdf = {0}; However, this is not (always) legal in C++. Certain versions of afl-clang are more C++-leaning and produce warnings about uninitialized fields even when compiling C code. Well, okay, I don't want to fence this code with suppressions, so replace this initialization is explicit memset() calls.
- Loading branch information