https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100765

            Bug ID: 100765
           Summary: attribute incorrectly applied during type alias
                    deduction
           Product: gcc
           Version: 12.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: rustamabd at gmail dot com
  Target Milestone: ---

template <typename T>
using vec __attribute__((vector_size(8))) = T;

template <typename T>
void test(vec<T> x) {}

int main() {
  test(vec<int>{1,2});
}

Compiles fine in Clang, but fails in GCC with:

In substitution of 'template<class T> using vec = T [with T = __vector(2)
int]':
   required by substitution of 'template<class T> void test(vec<T>) [with T =
__vector(2) int]'
   required from here
 error: invalid vector type for attribute 'vector_size'
    2 | using vec __attribute__((vector_size(8))) = T;
      |       ^~~

GCC seems to be applying __attribute__(vector_size) to int when deducing from
vec<int>.

Bypassing deduction makes the code compile:

  test<int>(vec<int>{1,2});

This issue seems to exist in all GCC versions starting from 4.7.0 until at
least the current (12.0) trunk.

Reply via email to