Skip to content
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

flat_set: undefined behaviour on empty range #76

Closed
gjasny opened this issue Jun 27, 2018 · 3 comments
Closed

flat_set: undefined behaviour on empty range #76

gjasny opened this issue Jun 27, 2018 · 3 comments

Comments

@gjasny
Copy link

gjasny commented Jun 27, 2018

Hello,

the following code triggers the undefined behaviour sanitiser:

#include <cstdint>
#include <boost/container/flat_set.hpp>

using PacketSet = boost::container::flat_set<std::uint32_t>;

int main(int argc, const char * argv[]) {

    const PacketSet empty;
    PacketSet target;
    target.insert(empty.begin(), empty.end());

    return 0;
}

Output is:

boost/V1.67.0_6/boost/container/vector.hpp:125:14: runtime error: reference binding to null pointer of type 'unsigned int'
boost/V1.67.0_6/boost/container/vector.hpp:128:76: runtime error: reference binding to null pointer of type 'unsigned int'
boost/V1.67.0_6/boost/intrusive/pointer_traits.hpp:292:49: runtime error: reference binding to null pointer of type 'unsigned int'
boost/V1.67.0_6/boost/move/detail/meta_utils.hpp:270:49: runtime error: reference binding to null pointer of type 'unsigned int'
boost/V1.67.0_6/boost/move/detail/meta_utils.hpp:246:55: runtime error: reference binding to null pointer of type 'unsigned int'
boost/V1.67.0_6/boost/move/detail/meta_utils.hpp:247:57: runtime error: reference binding to null pointer of type 'unsigned int'
boost/V1.67.0_6/boost/move/detail/meta_utils.hpp:270:9: runtime error: reference binding to null pointer of type 'unsigned int'

Thanks,
Gregor

@gjasny
Copy link
Author

gjasny commented Jun 27, 2018

@igaztanaga: I don't know if you get notified automatically.

igaztanaga added a commit that referenced this issue Jun 27, 2018
@igaztanaga
Copy link
Member

It seems that

b56cbb6

fixes it (operator-> should not be based on operator*). Thanks for the report.

@gjasny
Copy link
Author

gjasny commented Jun 28, 2018

Thanks, verified.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants