<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 - taking address of function is not allowed enabling __cl_clang_function_pointers"
   href="https://bugs.llvm.org/show_bug.cgi?id=49264">49264</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>taking address of function is not allowed enabling __cl_clang_function_pointers
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>new-bugs
          </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>new bugs
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>matteo.concas@cern.ch
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>htmldeveloper@gmail.com, llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Created <span class=""><a href="attachment.cgi?id=24553" name="attach_24553" title="Makefile with reproducer and workaround files">attachment 24553</a> <a href="attachment.cgi?id=24553&action=edit" title="Makefile with reproducer and workaround files">[details]</a></span>
Makefile with reproducer and workaround files

LSB Release:
LSB Version:   
:core-4.1-amd64:core-4.1-noarch:cxx-4.1-amd64:cxx-4.1-noarch:desktop-4.1-amd64:desktop-4.1-noarch:languages-4.1-amd64:languages-4.1-noarch:printing-4.1-amd64:printing-4.1-noarch
Distributor ID: CentOS
Description:    CentOS Linux release 8.3.2011
Release:        8.3.2011
Codename:       n/a

Clang version:
clang version 13.0.0 (<a href="https://github.com/llvm/llvm-project.git">https://github.com/llvm/llvm-project.git</a>
a874d182c61c7f8e5291c718b40be0e133bf21f0)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /opt/clang/bin

Issue:
Passing a static constexpr function as an argument to another function as done
here (see reproducer.cl in attached archive):

namespace namespace row_offsets_utils
{

[omitted, see attached files for full reproducer]

template <int I0, class F, int... I>
constexpr auto do_make(F f, indices<I...>) -> o2::gpu::gpustd::array<int,
sizeof...(I)>
{
  o2::gpu::gpustd::array<int, sizeof...(I)> retarr = {f(I0 + I)...};
  return retarr;
}

template <int N, int I0 = 0, class F>
constexpr auto make(F f) -> o2::gpu::gpustd::array<int, N>
{
  return do_make<I0>(f, typename make_indices<N>::type());
}
}

template <class T, unsigned int D>
class MatRepSymGPU
{

[omitted, see attachd files for full reproducer]

static constexpr int off1(int i) { return off2(i / D, i % D); }

static int off(int i)
{
  static constexpr auto v = row_offsets_utils::make<D * D>(off1);
  return v[i];
}
};

breaks compilation with:

error: taking address of function is not allowed
  static constexpr auto v = row_offsets_utils::make<D * D>(off1);
                                                           ^
1 error generated.


I know this is not supported by OpenCL itself, but I had expected it to work
with __cl_clang_function_pointers, particularly since the slightly modified
version of the code compiles (see workaround.cl in attached archive).</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>