<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 constructors for data types from -finclude-default-header"
   href="https://bugs.llvm.org/show_bug.cgi?id=42387">42387</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>constexpr constructors for data types from -finclude-default-header
          </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>The following code

struct float3a { float x, y, z; };

constexpr float3 crossProduct(const float3& firstVector, const float3&
secondVector)
{
  return float3{ (firstVector.y * secondVector.z) - (firstVector.z *
secondVector.y),
                 (firstVector.z * secondVector.x) - (firstVector.x *
secondVector.z),
                 (firstVector.x * secondVector.y) - (firstVector.y *
secondVector.x) };
}

constexpr float3a crossProduct(const float3& firstVector, const float3&
secondVector)
{
  return float3a{ (firstVector.y * secondVector.z) - (firstVector.z *
secondVector.y),
                 (firstVector.z * secondVector.x) - (firstVector.x *
secondVector.z),
                 (firstVector.x * secondVector.y) - (firstVector.y *
secondVector.x) };
}

compiled with "clang++ -cl-std=c++ -Xclang -finclude-default-header" fails with

test.cl:3:18: error: constexpr function never produces a constant expression
[-Winvalid-constexpr]
constexpr float3 crossProduct(const float3& firstVector, const float3&
secondVector)
                 ^
test.cl:5:19: note: subexpression not valid in a constant expression
  return float3{ (firstVector.y * secondVector.z) - (firstVector.z *
secondVector.y),
                  ^
test.cl:10:19: error: functions that differ only in their return type cannot be
overloaded
constexpr float3a crossProduct(const float3& firstVector, const float3&
secondVector)
          ~~~~~~~ ^
test.cl:3:18: note: previous definition is here
constexpr float3 crossProduct(const float3& firstVector, const float3&
secondVector)

since apparently one cannot create a float3 from -finclude-default-header in a
constexpr way, while it works with the manually-defined float3a.</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>