[llvm-bugs] [Bug 51320] New: __constant__ variable in anonymous namespace is optimized as if it could not be modified

via llvm-bugs llvm-bugs at lists.llvm.org
Tue Aug 3 06:20:57 PDT 2021


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

            Bug ID: 51320
           Summary: __constant__ variable in anonymous namespace is
                    optimized as if it could not be modified
           Product: clang
           Version: 12.0
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: CUDA
          Assignee: unassignedclangbugs at nondot.org
          Reporter: kiwixz at outlook.com
                CC: llvm-bugs at lists.llvm.org

Created attachment 25102
  --> https://bugs.llvm.org/attachment.cgi?id=25102&action=edit
code sample showcasing the issue

The best way to understand it is by looking at the attached code sample.

I tested it with: clang++ -L/usr/local/cuda/lib64 -lcudart
--cuda-gpu-arch=sm_30 -O3 main.cu && ./a.out

It works without `-O3`.

Expected output:
good = 10
bad = 20
good = 110
bad = 120

Bad output:
good = 10
bad = 20
good = 110
bad = 20

-- 
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/20210803/a7ba56cb/attachment.html>


More information about the llvm-bugs mailing list