re PR c++/78006 (Segmentation fault with 'using' and generic lambda trailing return...
authorPaolo Carlini <paolo.carlini@oracle.com>
Tue, 10 Oct 2017 20:46:26 +0000 (20:46 +0000)
committerPaolo Carlini <paolo@gcc.gnu.org>
Tue, 10 Oct 2017 20:46:26 +0000 (20:46 +0000)
2017-10-10  Paolo Carlini  <paolo.carlini@oracle.com>

PR c++/78006
* g++.dg/cpp1y/auto-fn40.C: New.

From-SVN: r253621

gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/cpp1y/auto-fn40.C [new file with mode: 0644]

index 14c2a5ad907e2bb36fbdd29bd0eb053bfcec556c..b44242014e3e94c39c96fc1716eee4ab64151640 100644 (file)
@@ -1,3 +1,8 @@
+2017-10-10  Paolo Carlini  <paolo.carlini@oracle.com>
+
+       PR c++/78006
+       * g++.dg/cpp1y/auto-fn40.C: New.
+
 2017-10-10  Paolo Carlini  <paolo.carlini@oracle.com>
 
        PR c++/81032
diff --git a/gcc/testsuite/g++.dg/cpp1y/auto-fn40.C b/gcc/testsuite/g++.dg/cpp1y/auto-fn40.C
new file mode 100644 (file)
index 0000000..e7f1bd4
--- /dev/null
@@ -0,0 +1,37 @@
+// PR c++/78006
+// { dg-do compile { target c++14 } }
+
+template<typename T> T&& declval() noexcept;
+
+template<typename... _Tp>
+  struct common_type;
+
+template<typename _Tp>
+  struct common_type<_Tp>
+  { typedef _Tp type; };
+
+template<typename _Tp, typename _Up>
+  struct common_type<_Tp, _Up>
+  { typedef decltype(true ? declval<_Tp>() : declval<_Up>()) type; };
+
+template<typename _Tp, typename _Up, typename... _Vp>
+  struct common_type<_Tp, _Up, _Vp...>
+  {
+    typedef typename
+      common_type<typename common_type<_Tp, _Up>::type, _Vp...>::type type;
+  };
+
+template<typename... _Tp>
+  using common_type_t = typename common_type<_Tp...>::type;
+
+template <typename... TFs>
+auto x(TFs&&... fs)
+{
+  using rt = common_type_t<decltype(fs(0))...>;    
+  return [](auto) -> rt { };    
+}
+
+int main()
+{
+  x([](int){})(0);    
+}