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.
Hm, I think we should document this behaviour in the header.
There was a problem hiding this comment.
No. This is a logical error to do this.
There was a problem hiding this comment.
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.
Taking the iterator is fine, but you cannot dereference it when it is the end iterator.
There was a problem hiding this comment.
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.
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.