Fix strict aliasing violations in gl3cCommonBugsTests
authorNeil Roberts <nroberts@igalia.com>
Wed, 15 Nov 2017 21:45:39 +0000 (22:45 +0100)
committerNeil Roberts <nroberts@igalia.com>
Thu, 16 Nov 2017 09:32:44 +0000 (10:32 +0100)
commitea8e2cf8f206dab171439595a9644019eb543cbc
tree5035074ea749958148b1bf4504ce5716e9ed6174
parentb593d1eaed82bc56dd15253eb67d13a90a0f5c8f
Fix strict aliasing violations in gl3cCommonBugsTests

In two places in PerVertexValidationTest::getTestIterationProperties
it first stores a value in a pointer to an enum and then later tries
to update the enum via a reference casted to an int reference. I
believe this violates the strict aliasing rules and so is undefined
behaviour. At least with gcc and -O2 the compiler seems to take
advantage of this and effectively ignores the initial assignment of
SHADER_STAGE_VERTEX for the PERVERTEX_DECLARATION_MISMATCH_TC_TE_VS
iteration. The result is that used_shader_stages gets or’d with an
unitialised value. This was causing a valgrind error and depending on
what the original value happened to be it can make the test
erroneously fail.

Modules: OpenGL

VK-GL-CTS issue: 853

Affects:
KHR-GL*.CommonBugs.CommonBug_PerVertexValidation

Change-Id: I1094de5c2114c035e339cdb524808f45cbe55782
external/openglcts/modules/gl/gl3cCommonBugsTests.cpp