http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58855

            Bug ID: 58855
           Summary: Attributes ignored on type alias in template
           Product: gcc
           Version: 4.9.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: st at quanttec dot com

When compiling the following example the current trunk version of GCC accepts
the attribute in the typedef but not the semantically equivalent type alias. 

template <typename T>
void test(T*) {
  using T0 = int __attribute__((aligned(1)));
  static_assert(alignof(T0) == 1, "wrong alignment"); // no error

  typedef T __attribute__((aligned(1))) T1;
  static_assert(alignof(T1) == 1, "wrong alignment"); // no error

  using T2 = T __attribute__((aligned(1)));
  static_assert(alignof(T2) == 1, "wrong alignment"); // error
}

int main() {
  test((int*)0);
  return 0;
}

> g++ -std=c++11 -Wall -Wextra test.cpp
test.cpp: In function ‘void test(T*)’:
test.cpp:9:42: warning: ignoring attributes applied to dependent type ‘T’
without an associated declaration [-Wattributes]
   using T2 = T __attribute__((aligned(1)));
                                          ^
test.cpp: In instantiation of ‘void test(T*) [with T = int]’:
test.cpp:14:15:   required from here
test.cpp:10:3: error: static assertion failed: wrong alignment
   static_assert(alignof(T2) == 1, "wrong alignment"); // error
   ^

Reply via email to