[llvm-bugs] [Bug 47379] New: error: non-const reference cannot bind to vector element

via llvm-bugs llvm-bugs at lists.llvm.org
Tue Sep 1 01:22:45 PDT 2020


https://bugs.llvm.org/show_bug.cgi?id=47379

            Bug ID: 47379
           Summary: error: non-const reference cannot bind to vector
                    element
           Product: clang
           Version: unspecified
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: C++
          Assignee: unassignedclangbugs at nondot.org
          Reporter: mliska at suse.cz
                CC: blitzrakete at gmail.com, dgregor at apple.com,
                    erik.pilkington at gmail.com, llvm-bugs at lists.llvm.org,
                    richard-llvm at metafoo.co.uk

The following code can be accepted by GCC, but not with clang:

$ cat clang-vector-access.cpp
template <typename T, int N>
struct Polyfill {
   using Vec __attribute__ ((vector_size (sizeof(T) * N))) = T;  

   Vec v;

   T& operator[](int k)       { return v[k]; }
};

int main()
{
  Polyfill<float, 8> x, y;
  x[3] = y[2];
}

$ clang++ clang-vector-access.cpp
clang-vector-access.cpp:7:40: error: non-const reference cannot bind to vector
element
   T& operator[](int k)       { return v[k]; }
                                       ^~~~
clang-vector-access.cpp:13:4: note: in instantiation of member function
'Polyfill<float, 8>::operator[]' requested here
  x[3] = y[2];
   ^
1 error generated.

$ g++ clang-vector-access.cpp

I see it handy to be able to access a vector element.

-- 
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/20200901/9b47034f/attachment.html>


More information about the llvm-bugs mailing list