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

Better out-of-bounds checks for collection access #458

Closed
tmadlener opened this issue Jul 21, 2023 · 0 comments · Fixed by #570
Closed

Better out-of-bounds checks for collection access #458

tmadlener opened this issue Jul 21, 2023 · 0 comments · Fixed by #570

Comments

@tmadlener
Copy link
Collaborator

          I feel like here going out of range may be more of a problem than in C++ (this is not related to this PR but just indexing out of range a `std::deque`):
event = Frame()
hits = ExampleHitCollection()
hits[0] # seg fault
hits[1] # <cppyy.gbl.MutableExampleHit object at 0x55dcd5d30d50>
hits[1].x() # seg fault
hits.create(0, 1, 2. 3, 4)
hits[0] # <cppyy.gbl.MutableExampleHit object at 0x55dcc4324040>
hits[1] # <cppyy.gbl.MutableExampleHit object at 0x55dcd5d572b0>
hits[2] # seg fault

It's inconsistent since the behavior is undefined, could be a bit hard to debug when you go out of range and it may seem to work but then it doesn't later on. I'm not sure if there are options, not checking in C++ I think is a design choice since there is also .at, but in python no one is going to use that probably

Originally posted by @jmcarcell in #447 (comment)

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

Successfully merging a pull request may close this issue.

1 participant