clang 4使用c ++ 1z在<functional>上构建错误

时间:2017-05-30 12:25:45

标签: c++ archlinux clang++ c++17

我刚刚将我的arch linux系统更新到包含gcc 7.1.1的最新版本。试图建立这个:

#include <functional>

int main(int argc, char** argv) {
    return 1;
}

使用命令

clang++ main.cpp -std=c++1z

导致错误:

In file included from main.cpp:1:
In file included from /usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/7.1.1/../../../../include/c++/7.1.1/functional:60:
In file included from /usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/7.1.1/../../../../include/c++/7.1.1/unordered_map:47:
In file included from /usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/7.1.1/../../../../include/c++/7.1.1/bits/hashtable.h:37:
In file included from /usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/7.1.1/../../../../include/c++/7.1.1/bits/node_handle.h:39:
/usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/7.1.1/../../../../include/c++/7.1.1/optional:1032:27: error: use of class template 'optional'
      requires template arguments
  template <typename _Tp> optional(_Tp) -> optional<_Tp>;
                          ^
/usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/7.1.1/../../../../include/c++/7.1.1/optional:451:11: note: template is declared here
    class optional
          ^
/usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/7.1.1/../../../../include/c++/7.1.1/optional:1032:40: error: expected ';' at end of declaration
  template <typename _Tp> optional(_Tp) -> optional<_Tp>;
                                       ^
/usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/7.1.1/../../../../include/c++/7.1.1/optional:1032:41: error: cannot use arrow operator on a type
  template <typename _Tp> optional(_Tp) -> optional<_Tp>;

这对我来说是个错误吗?是linux,还是clang?

更新:(忘了添加版本)

  • gcc包版本7.1.1-2(提供/ usr / include / c ++ dir)
  • clang package version 4.0.0-3

1 个答案:

答案 0 :(得分:7)

不太晚,但我想总结一下。

此:

template <typename _Tp> optional(_Tp) -> optional<_Tp>;

是演绎指南的示例。 Here您可以找到有关此语言功能的精彩解释。

当-std = c ++ 17或c ++ 1z标志正在使用时,新版本的libstdc ++在其实现中使用它。 不幸的是,Clang还不支持此功能。 Clang C++1z status page报告仅在SVN上提供。

您可以找到Arch Linux here的错误报告。