[llvm-bugs] [Bug 45024] New: Cannot write to std::array inside CUDA __device__ lambda

via llvm-bugs llvm-bugs at lists.llvm.org
Tue Feb 25 13:48:26 PST 2020


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

            Bug ID: 45024
           Summary: Cannot write to std::array inside CUDA __device__
                    lambda
           Product: clang
           Version: 9.0
          Hardware: PC
                OS: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: -New Bugs
          Assignee: unassignedclangbugs at nondot.org
          Reporter: rgovostes at gmail.com
                CC: htmldeveloper at gmail.com, llvm-bugs at lists.llvm.org,
                    neeilans at live.com, richard-llvm at metafoo.co.uk

--------
#include <array>

int main() {
        auto l = [] __device__ () {
                std::array<int, 1> x;
                x[0] = 1;
        };
        return 0;
}
--------

When compiled with `clang++ -std=c++14 test.cu` this fails with:

test.cu:6:8: error: cannot assign to return value because function 'operator[]'
returns a const value
                x[0] = 1;
                ~~~~ ^

This appears only to be the case if this is a __device__ lambda. Otherwise the
array is writable as expected.

-- 
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/20200225/e04f1054/attachment.html>


More information about the llvm-bugs mailing list