-
Notifications
You must be signed in to change notification settings - Fork 34
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
Adjust OperandStack allocation size when no locals #630
Conversation
Codecov Report
@@ Coverage Diff @@
## master #630 +/- ##
=======================================
Coverage 99.30% 99.30%
=======================================
Files 72 72
Lines 10300 10312 +12
=======================================
+ Hits 10228 10240 +12
Misses 72 72
Flags with carried forward coverage won't be shown. Click here to find out more.
|
|
||
// Even when stack is empty, there exists a single hidden item slot. | ||
const_cast<fizzy::Value*>(stack.rbegin())->i64 = 1; | ||
EXPECT_EQ(stack.rbegin()->i64, 1); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hm, I think we should document this behaviour in the header.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No. This is a logical error to do this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The documentation (https://en.cppreference.com/w/cpp/iterator/begin) doesn't state anywhere that begin()
would be UB in case of size() == 0
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@chfast any feedback?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Taking the iterator is fine, but you cannot dereference it when it is the end iterator.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But here you are dereferencing it?
To be honest at this stage I lost what the conversation is about.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah okay, we do ensure that begin() == end()
, just that we know begin()
is always valid.
@chfast can this be merged? |
If you really want to. |
Fixes #583.