<html>
    <head>
      <base href="https://bugs.llvm.org/">
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - Problem in C++4OpenCL calling copy constructor from object in __constant addr space"
   href="https://bugs.llvm.org/show_bug.cgi?id=50164">50164</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Problem in C++4OpenCL calling copy constructor from object in __constant addr space
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>clang
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>trunk
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>Linux
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>enhancement
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>OpenCL
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedclangbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>drohr@jwdt.org
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>anastasia.stulova@arm.com, llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Created <span class=""><a href="attachment.cgi?id=24812" name="attach_24812" title="testcase">attachment 24812</a> <a href="attachment.cgi?id=24812&action=edit" title="testcase">[details]</a></span>
testcase

The attached test case fails to compile in C++4OpenCL with a problem invoking
the copy constructor from an object in constant address space. If I make the
member of the object private and access it directly, feeding it in a
constructor again, bypassing the pass-by-reference to the copy constructor, it
actually works (done in workaround.patch). But I'd prefer to find a proper
solution.

Note: the test case requires <a href="https://reviews.llvm.org/D101168">https://reviews.llvm.org/D101168</a>.
I have been testing with clang trunk (clang version 13.0.0
(<a href="https://github.com/llvm/llvm-project.git">https://github.com/llvm/llvm-project.git</a>
837fded984ed36fa462daeb0f671eec58f71ae26)) + <a href="https://reviews.llvm.org/D101168">https://reviews.llvm.org/D101168</a>
and with the following command line:
/home/qon/alice/llvm-project/build/bin/clang++ -O0 -cl-std=clc++ -x cl
-emit-llvm --target=spir64-unknown-unknown -Xclang -fdenormal-fp-math-f32=ieee
-cl-mad-enable -cl-no-signed-zeros -ferror-limit=1000
-Dcl_clang_storage_class_specifiers -c fail.cl -o test.bc

(I am not sure whether this is related to
<a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - C++ for OpenCL fails to use constexpr construcor to create variable in __constant space"
   href="show_bug.cgi?id=50163">https://bugs.llvm.org/show_bug.cgi?id=50163</a>, but the error message is
different, so I am opening an independent bug report)

The error I am getting in the compilation is:
In file included from ../Base/opencl-common/GPUReconstructionOCL.cl:80:
In file included from ../Base/GPUReconstructionIncludesDevice.h:31:
In file included from ../SliceTracker/GPUTPCTracker.cxx:21:
In file included from ../SliceTracker/GPUTPCTrackletConstructor.h:20:
In file included from ../Base/GPUConstantMem.h:25:
In file included from ../TRDTracking/GPUTRDTracker.h:23:
In file included from ../TRDTracking/GPUTRDTrack.h:46:
In file included from ../TRDTracking/GPUTRDInterfaces.h:140:
In file included from
/home/qon/alice/O2/DataFormats/Reconstruction/include/ReconstructionDataFormats/TrackTPCITS.h:20:
In file included from
/home/qon/alice/O2/DataFormats/Reconstruction/include/ReconstructionDataFormats/GlobalTrackID.h:20:
/home/qon/alice/O2/DataFormats/Detectors/Common/include/DetectorsCommonDataFormats/DetID.h:189:63:
error: no matching constructor for initialization of 'DetID::mask_t' (aka
'bitset<32>')
inline constexpr DetID::mask_t DetID::getMask(ID id) { return
detid_internal::sMasks[id]; }
                                                             
^~~~~~~~~~~~~~~~~~~~~~~~~~
../GPUUtils/GPUCommonBitSet.h:38:27: note: candidate constructor not viable:
cannot bind reference in address space '__constant' to object in address space
'__generic' in 1st argument
                constexpr bitset(const bitset&) = default;
                          ^
../GPUUtils/GPUCommonBitSet.h:39:20: note: candidate constructor not viable: no
known conversion from '__constant DetID::mask_t' (aka '__constant bitset<32>')
to '__private unsigned int' for 1st argument
         constexpr bitset(unsigned int vv) : v(vv){};
                   ^
../GPUUtils/GPUCommonBitSet.h:37:27: note: candidate constructor not viable:
requires 0 arguments, but 1 was provided
                constexpr bitset() = default;
                          ^</pre>
        </div>
      </p>


      <hr>
      <span>You are receiving this mail because:</span>

      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>