[LLVMbugs] [Bug 15730] New: __attribute__((vector)) and templates

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Fri Apr 12 00:45:47 PDT 2013


http://llvm.org/bugs/show_bug.cgi?id=15730

            Bug ID: 15730
           Summary: __attribute__((vector)) and templates
           Product: clang
           Version: 3.2
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: Frontend
          Assignee: unassignedclangbugs at nondot.org
          Reporter: giulio.eulisse at cern.ch
                CC: llvmbugs at cs.uiuc.edu
    Classification: Unclassified

Hi,

the following bit of code:

template <int N, typename T> struct Foo
{
  typedef T __attribute__((vector_size(N*sizeof(T)))) type;
};

compiles fine with gcc 4.7.2, however when compiled with clang 3.2 I get:

foo.cc:4:41: error: expected ')'
  typedef T __attribute__((vector_size(N*sizeof(T)))) type;
                                        ^
                                        )
foo.cc:4:41: error: expected ')'
  typedef T __attribute__((vector_size(N*sizeof(T)))) type;
                                        ^
                                        )
foo.cc:4:53: error: expected member name or ';' after declaration specifiers
  typedef T __attribute__((vector_size(N*sizeof(T)))) type;
  ~~~~~~~~~                                         ^

Moreover even doing:

template <int N, typename T> struct Foo
{
  typedef T __attribute__((vector_size(16))) type;
};

does not work and gives:

foo.cc:4:28: error: invalid vector element type 'T'
  typedef T __attribute__((vector_size(16))) type;
                           ^

The only way to get it to work is to eliminate the dependency on the T template
argument:

template <int N, typename T> struct Foo
{
  typedef int __attribute__((vector_size(16))) type;
};

compiles fine on both clang 3.2 and gcc 4.7.2

Any idea?

Ciao,
Giulio

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20130412/f4d75694/attachment.html>


More information about the llvm-bugs mailing list