LLVM Bugzilla is read-only and represents the historical archive of all LLVM issues filled before November 26, 2021. Use github to submit LLVM bugs

Bug 15730 - __attribute__((vector_size)) and templates
Summary: __attribute__((vector_size)) and templates
Status: CONFIRMED
Alias: None
Product: clang
Classification: Unclassified
Component: Frontend (show other bugs)
Version: trunk
Hardware: PC Linux
: P normal
Assignee: Unassigned Clang Bugs
URL:
Keywords: new-feature
: 16986 34878 (view as bug list)
Depends on:
Blocks:
 
Reported: 2013-04-12 02:45 PDT by Giulio Eulisse
Modified: 2020-08-05 03:40 PDT (History)
8 users (show)

See Also:
Fixed By Commit(s):


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Giulio Eulisse 2013-04-12 02:45:47 PDT
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
Comment 1 Paul Keir 2014-06-14 16:25:15 PDT
I see this too under Ubuntu 14.04 with clang version 3.5.0 (trunk 210014).
Comment 2 Alexey Frolov 2015-05-26 04:19:36 PDT
I'm gonna handle this one by changing vector_size attribute to have an AST node (as aligned and align_value attributes do, for example).

Alexey Frolov
=============
Software Engineer
Intel Compiler Team
Intel
Comment 3 Lars Frydendal Bonnichsen 2020-08-05 03:05:43 PDT
Is anyone assigned to this issue?
It seems like Alexey Frolov is not working for Intel anymore, and the most recent activity was a discussion on how to resolve the issue http://lists.llvm.org/pipermail/cfe-dev/2015-June/043653.html

I'm pretty sure https://bugs.llvm.org/show_bug.cgi?id=34878 is a duplicate of this issue.

Best regards,
Lars Bonnichsen
Comment 4 Lars Frydendal Bonnichsen 2020-08-05 03:30:01 PDT
https://bugs.llvm.org/show_bug.cgi?id=16986 looks like another duplicate, and it seems the issue was solved in clang 9, yay. /Lars
Comment 5 Lars Frydendal Bonnichsen 2020-08-05 03:39:36 PDT
*** Bug 16986 has been marked as a duplicate of this bug. ***
Comment 6 Lars Frydendal Bonnichsen 2020-08-05 03:40:15 PDT
*** Bug 34878 has been marked as a duplicate of this bug. ***