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

            Bug ID: 69022
           Summary: attribute vector_size ignored with dependent bytes
           Product: gcc
           Version: 6.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: msebor at gcc dot gnu.org
  Target Milestone: ---

While working on a fix for bug 58109 (and bug 69020) I came across another
instance of attribute vector_size not being handled correctly (in addition to
bug 35758 and bug 38260).  In the following test case, the attribute is
accepted on all declarations except that of c.  As in bug 58109, the problem in
this case also seems to be in the is_late_template_attribute() function which
fails to treat the argument as dependent.

$ cat x.cpp && /build/gcc-trunk-svn/gcc/xg++ -B /build/gcc-trunk-svn/gcc -S
-Wall -Wextra -Wpedantic -o/dev/null x.cpp 
template <int N>
struct A { static const int X = N; };

#define ASSERT(e) static_assert (e, #e)

template <class T, int N>
struct B: A<N>
{
    using A<N>::X;

    static void foo ()
    {
        char a __attribute__ ((vector_size (N)));
        ASSERT (sizeof a == N);

        T b __attribute__ ((vector_size (N)));
        ASSERT (sizeof b == N);
    }

    static void bar ()
    {
        char c __attribute__ ((vector_size (X)));
        ASSERT (sizeof c == X);

        T d __attribute__ ((vector_size (X)));
        ASSERT (sizeof d == X);
    }
};

void bar ()
{
    B<int, 16>::foo ();
    B<int, 16>::bar ();
}

x.cpp: In static member function ‘static void B<T, N>::bar()’:
x.cpp:22:48: warning: ‘vector_size’ attribute ignored [-Wattributes]
         char c __attribute__ ((vector_size (X)));
                                                ^

x.cpp: In instantiation of ‘static void B<T, N>::bar() [with T = int; int N =
16]’:
x.cpp:33:17:   required from here
x.cpp:4:19: error: static assertion failed: sizeof c == X
 #define ASSERT(e) static_assert (e, #e)
                   ^

x.cpp:23:9: note: in expansion of macro ‘ASSERT’
         ASSERT (sizeof c == X);
         ^~~~~~

Reply via email to