http://llvm.org/bugs/show_bug.cgi?id=22479

            Bug ID: 22479
           Summary: compiler crash when doing lambda magic
           Product: clang
           Version: unspecified
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: C++11
          Assignee: [email protected]
          Reporter: [email protected]
                CC: [email protected], [email protected]
    Classification: Unclassified

Created attachment 13813
  --> http://llvm.org/bugs/attachment.cgi?id=13813&action=edit
the required attackment

Try compiling this and you'll get a crash:

#ifndef GENERIC_CIFY_HPP
# define GENERIC_CIFY_HPP
# pragma once

#include <utility>

namespace generic
{

namespace
{

template <typename F, int I, typename L, typename R, typename ...A>
inline F cify(L&& l, R (*)(A...))
{
  static thread_local L l_(::std::forward<L>(l));
  static thread_local bool full;

  if (full)
  {
    l_.~L();
    new (static_cast<void*>(&l_)) L(::std::forward<L>(l));
  }
  else
  {
    full = true;
  }

  return [](A... args) noexcept(noexcept(l_(::std::forward<A>(args)...))) {
    return l_(::std::forward<A>(args)...);
  };
}

}

template <typename F, int I = 0, typename L>
inline F cify(L&& l)
{
  return cify<F, I>(::std::forward<L>(l), F());
}

}

#endif // GENERIC_CIFY_HPP

#include <iostream>

int main()
{
  int a;

  auto const f(::generic::cify<void(*)()>([a]{::std::cout << "a: " << a <<
::std::endl;}));

  f();

  return 0;
}

-- 
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
LLVMbugs mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/llvmbugs

Reply via email to