Fix undertermined execution behavior (#4751)
Fix for the issue #4744: Ambiguous side-effect execution on vector_downward::make_space() method. C++ does not impose evaluation order on the two expressions on the right side of the assignment, so compiler can freely decide. As ensure_space() method can change the value of "cur_" variable, the result of the subtraction may be different depending on the evaluation order, which is ambiguous in C++. In order to make this code deterministic and correct, cur_ must be evaluated after ensure_space() is called.
This commit is contained in:
parent
a9640bd9e1
commit
c43a0beff0
|
@ -601,7 +601,8 @@ class vector_downward {
|
|||
}
|
||||
|
||||
inline uint8_t *make_space(size_t len) {
|
||||
cur_ -= ensure_space(len);
|
||||
size_t space = ensure_space(len);
|
||||
cur_ -= space;
|
||||
return cur_;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue