https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92745
Bug ID: 92745
Summary: Initializing array with vec4 results in compile error
Product: gcc
Version: 8.3.0
URL: https://gcc.godbolt.org/z/sxvR3G
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: milasudril at gmail dot com
Target Milestone: ---
Target: Any
In GCC 8.3 and later the following code fails to compile:
#include <array>
template<class T>
using vec4_t __attribute__((vector_size(4*sizeof(T)))) = float;
auto transpose(std::array<vec4_t<float>, 4> col)
{
std::array<vec4_t<float>, 4> ret{vec4_t<float>{col[0][0], col[1][0],
col[2][0], col[3][0]},
vec4_t<float>{col[0][1], col[1][1],
col[2][1], col[3][1]},
vec4_t<float>{col[0][2], col[1][2],
col[2][2], col[3][2]},
vec4_t<float>{col[0][3], col[1][3],
col[2][3], col[3][3]}};
return ret;
}
x86-64 gcc 8.3
-O3
1
<Compilation failed>
x86-64 gcc 8.3 - 1240ms
<source>: In function 'auto transpose(std::array<__vector(4) float, 4>)':
<source>:11:102: error: too many initializers for 'std::array<__vector(4)
float, 4>'
vec4_t<float>{col[0][3],
col[1][3], col[2][3], col[3][3]}};
^
Compiler returned: 1
It compiles with GCC 8.2 and earlier, and also the latest version of clang.