<html>
    <head>
      <base href="http://llvm.org/bugs/" />
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW --- - __attribute__((vector)) and templates"
   href="http://llvm.org/bugs/show_bug.cgi?id=15730">15730</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>__attribute__((vector)) and templates
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>clang
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>3.2
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>Linux
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>normal
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>Frontend
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedclangbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>giulio.eulisse@cern.ch
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvmbugs@cs.uiuc.edu
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>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</pre>
        </div>
      </p>
      <hr>
      <span>You are receiving this mail because:</span>
      
      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>