<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 - Constexpr array not seen as constexpr"
   href="https://bugs.llvm.org/show_bug.cgi?id=44177">44177</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Constexpr array not seen as constexpr
          </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=22880" name="attach_22880" title="Testcase">attachment 22880</a> <a href="attachment.cgi?id=22880&action=edit" title="Testcase">[details]</a></span>
Testcase

The attached code (which works correctly with standard C++, and also with CUDA)
fails in OpenCL because the constexpr array zSize is not interpreted as
constexpr.

Command to reproduce:
clang++ -cl-std=clc++ -Xclang -finclude-default-header -o test test2.cl

Error message:
test2.cl:54:57: error: constexpr function never produces a constant expression
[-Winvalid-constexpr]
GPU_HOST_DEVICE constexpr GPUArray<float, LayersNumber> InverseZBinSize()
                                                        ^
test2.cl:57:57: note: subexpression not valid in a constant expression
  return GPUArray<float, LayersNumber>{{0.5f * ZBins / (zSize[0]), 0.5f * ZBins
/ (zSize[1]), 0.5f * ZBins / (zSize[2]),</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>