Commit 37cb5af3 authored by Jose Dapena Paz's avatar Jose Dapena Paz Committed by Commit Bot

GCC: do not optimize destructors on VectorBuffer unit tests

On GCC builds with optimizations 3 VectorBuffer unit tests are failing:
DeleteMoveOnly, MovableMove and CopyableMove. This is because the tests
assume the original VectorBuffer items destructor will be invoked.

In the case of MoveOnlyInt and CopyOnlyInt, the destructor will set
the member int to 0. On GCC, in the test cases, those count as storage
after destruction, and optimized away by dead store elimination.

But setting the int as volatile will avoid the code being optimized
away, and fix the unit tests.

Change-Id: Ibad460d4f75b91cbcbaf935c32a6b9f8d1fd186a
Reviewed-on: https://chromium-review.googlesource.com/968844Reviewed-by: default avatarDaniel Cheng <dcheng@chromium.org>
Commit-Queue: José Dapena Paz <jose.dapena@lge.com>
Cr-Commit-Position: refs/heads/master@{#545097}
parent 192998b2
......@@ -44,7 +44,7 @@ class CopyOnlyInt {
int data() const { return data_; }
private:
int data_;
volatile int data_;
CopyOnlyInt(CopyOnlyInt&&) = delete;
CopyOnlyInt& operator=(CopyOnlyInt&) = delete;
......
......@@ -58,7 +58,7 @@ class MoveOnlyInt {
int data() const { return data_; }
private:
int data_;
volatile int data_;
DISALLOW_COPY_AND_ASSIGN(MoveOnlyInt);
};
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment