<html>
    <head>
      <base href="http://llvm.org/bugs/" />
    </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 --- - code compiles with g++-4.9.0, but not clang-3.4.2"
   href="http://llvm.org/bugs/show_bug.cgi?id=20195">20195</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>code compiles with g++-4.9.0, but not clang-3.4.2
          </td>
        </tr>

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

        <tr>
          <th>Version</th>
          <td>unspecified
          </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>normal
          </td>
        </tr>

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

        <tr>
          <th>Component</th>
          <td>C++11
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>janezz55@gmail.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>dgregor@apple.com, llvmbugs@cs.uiuc.edu
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>clang fails to compile this code with the error:

t.cpp:24:13: error: a lambda expression may not appear inside of a constant
expression
    address([](C* const object) noexcept {

#include <iostream>

#include <type_traits>

#include <utility>

#ifndef MEMBER
# define MEMBER(f) decltype(&f),&f
#endif // MEMBER

namespace detail
{

template <typename T>
auto address(T&& t) -> typename ::std::remove_reference<T>::type*
{
  return &t;
}

template <typename FP, FP fp, class C, typename ...A>
struct S
{
  static constexpr auto* l = false ?
    address([](C* const object) noexcept {
      return [object](A&& ...args) {
        return (object->*fp)(::std::forward<A>(args)...); 
      };
    }) :
    nullptr;
};

template <typename FP, FP fp, typename R, class C, typename ...A>
auto make_delegate(C* const object, R (C::* const)(A...)) ->
  decltype((*decltype(S<FP, fp, C, A...>::l)(nullptr))(object))
{
  return (*decltype(S<FP, fp, C, A...>::l)(nullptr))(object);
}

}

template <typename FP, FP fp, class C>
auto make_delegate(C* const object) ->
  decltype(detail::make_delegate<FP, fp>(object, fp))
{
  return detail::make_delegate<FP, fp>(object, fp);
}

struct A
{
  void operator()()
  {
    ::std::cout << "hello world" << ::std::endl;
  }
};

int main()
{
  A a;

  auto d(make_delegate<MEMBER(A::operator())>(&a));

  d();

  return 0;
}</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>