Clang cannot compile programs using the <functional> header

I use clangVersion 4.0.0 on my system using ArchLinux, it always worked fine, but lately I can no longer compile programs that use certain STL headers!

Details:

Conclusion clang --version:

 clang version 4.0.0 (tags/RELEASE_400/final)
 Target: x86_64-unknown-linux-gnu
 Thread model: posix
 InstalledDir: /usr/bin

Conclusion gcc --version:

 gcc (GCC) 7.1.1 20170528

Example:

I tried to compose the following trivial program:

#include <functional>

int main()
{
    return 0;
}

I use the following command:

clang++ -std=c++1z test.cxx

And the result is a failure:

In file included from test.cxx:3:
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>;
                                        ^
3 errors generated.

Is this an error in STL or is my configuration confused?

+6
source share
1 answer

Your setup is corrupt. Funny, I have the same problem.

gcc 7.1.1, ​​libstd++ ( gcc), ++ 17. gcc, , ++ 17.

clang . - -std=c++1z gcc -std=c++17. Clang , libstd++, , .

libstd++ ALA, / LLVM lib++, , , ++ 17.

+7

All Articles