[llvm-bugs] [Bug 35951] New: clang permits assignment to vector/extvector elements in a const method

via llvm-bugs llvm-bugs at lists.llvm.org
Mon Jan 15 07:06:13 PST 2018


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

            Bug ID: 35951
           Summary: clang permits assignment to vector/extvector elements
                    in a const method
           Product: clang
           Version: unspecified
          Hardware: PC
                OS: Windows NT
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: C++
          Assignee: unassignedclangbugs at nondot.org
          Reporter: llvm-dev at redking.me.uk
                CC: davide at freebsd.org, dgregor at apple.com,
                    filcab at gmail.com, llvm-bugs at lists.llvm.org,
                    richard-llvm at metafoo.co.uk, rjmccall at apple.com

The following cases compile successfully on clang but not gcc:

https://godbolt.org/g/jhQeot

#if __CLANG__
typedef float float4 __attribute__((ext_vector_type(4)));
struct OhNo {
  float4 v;
  void AssignMe() const { v.x = 1; }
};
#endif

typedef float float4_2 __attribute__((__vector_size__(16)));
struct OhNo2 {
  float4_2 v;
  void AssignMe() const { v[0] = 1; }
};

I'd expect clang to report an error that we are trying to assign a value to a
read-only variable, similar to:

struct OhNo3 {
  float v[4];
  void AssignMe() const { v[0] = 1; }
};

error: read-only variable is not assignable:
  void AssignMe() const { v[0] = 1; }

-- 
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/20180115/7491f640/attachment.html>


More information about the llvm-bugs mailing list