-
Notifications
You must be signed in to change notification settings - Fork 50
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Using end() instead of begin() + size() #606
Conversation
Updated functions that return iterator to the last element.
Hi, sudo apt-get -y update or for sudo apt-get -y install make autopoint texinfo libtool intltool bzip2 gettext clang-3.5 clang-4.0 g++-multilib They are not related to code test failures. I noticed this in all the builds that failed. I only replaced the statements that get the pointer to the iterator to one-after-the-last-element using Any inputs on why this would be causing code tests to fail, would be really helpful! Thanks |
I am fairly sure that dereferencing end() is undefined as it is past the end even though you don't actually read any memory. |
It originally was just Closing. |
Thanks, will take a look. |
Hi, I have one question though, why is
Any inputs or feedback on why there is a difference between the two implementations, would be very helpful! Thanks |
The problem is when the iterator is dereferenced, from https://en.cppreference.com/w/cpp/container/vector/end": This element acts as a placeholder; attempting to access it results in undefined behavior". |
Technically C++11 provides a data() method to vector so the correct solution would be to just use that, but I want to keep C++98 compatibility for now. I would accept a patch that redefines all relevant methods to use |
Hi, I'll start looking into the This is the first time, I'm working on a project so big. I have used GNU Aspell quite a few times and now trying to work on its source code, feels like a great way to contribute back to the project! Shall I keep posting my updates with regards to the patch in this thread itself? Thank you so much for your support. |
Hi, I have question, is it enough to verify that Any inputs or feedback on the implementations, would be very helpful! Thanks |
Just use |
Updated functions that return pointer to the iterator to the one-after-the-last-element's position in the vector to reduce the number of pointer dereferencing operations and improve code clarity.