https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82781
Bug ID: 82781
Summary: Vector extension operators return wrong result in
constexpr
Product: gcc
Version: 7.1.1
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: florent.hivert at lri dot fr
Target Milestone: ---
The following code shows the expected behavior of the == operator on vector:
#include<cassert>
using foo = int __attribute__ ((vector_size (16)));
int main() {
const foo b1 = {0, 1, 10, 20};
const foo b2 = {0, 2, 10, 0};
const foo b3 = b1 == b2;
assert (b3[0] == 0xffffffff);
assert (b3[1] == 0x0);
assert (b3[2] == 0xffffffff);
assert (b3[3] == 0x0);
}
However replacing const by constexpr breaks everything:
using foo = int __attribute__ ((vector_size (16)));
constexpr foo b1 = {0, 1, 10, 20};
constexpr foo b2 = {0, 2, 10, 0};
constexpr foo b3 = b1 == b2;
static_assert (b3[0] == 0xffffffff);
static_assert (b3[1] == 0x0);
static_assert (b3[2] == 0xffffffff);
static_assert (b3[3] == 0x0);
When compiled with
g++-7 -std=c++14 bug-const.cpp
gives
bug-const.cpp:8:1: error: l'assertion statique a échoué
static_assert (b3[1] == 0x0);
^~~~~~~~~~~~~
bug-const.cpp:10:1: error: l'assertion statique a échoué
static_assert (b3[3] == 0x0);
^~~~~~~~~~~~~
where is should pass.
Best,
Florent