FS#54276 - [clang] Latest gcc-libs (7.1.1) breaks clang in c++17 mode

Attached to Project: Arch Linux
Opened by sergio (sergio) - Friday, 02 June 2017, 19:37 GMT
Last edited by Evangelos Foutras (foutrelis) - Saturday, 16 September 2017, 19:53 GMT
Task Type Bug Report
Category Packages: Extra
Status Closed
Assigned To Evangelos Foutras (foutrelis)
Architecture x86_64
Severity Low
Priority Normal
Reported Version
Due in Version Undecided
Due Date Undecided
Percent Complete 100%
Votes 6
Private No

Details

Example:

#include <unordered_map>

int main()
{
return 0;
}



$ clang -std=c++1z example.cpp
In file included from a.cpp:1:
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.


clang from master branch works, so this seems to have been patched upstream already
This task depends upon

Closed by  Evangelos Foutras (foutrelis)
Saturday, 16 September 2017, 19:53 GMT
Reason for closing:  Fixed
Additional comments about closing:  clang 5.0.0-1
Comment by Evangelos Foutras (foutrelis) - Monday, 05 June 2017, 16:50 GMT
As per upstream's C++1z status page [1], support for template argument deduction for class templates exists only in SVN.

The changes to fix this are substantial and spread over many commits [2], so we will have to wait for a new clang release that officially supports this C++1z feature.

[1] https://clang.llvm.org/cxx_status.html#cxx17
[2] https://github.com/llvm-mirror/clang/search?utf8=%E2%9C%93&q=template+argument+deduction+for+class+templates&type=Commits
Comment by Hussam Al-Tayeb (hussam) - Monday, 05 June 2017, 17:10 GMT
Do any common projects require c++17 already?
Comment by sergio (sergio) - Tuesday, 06 June 2017, 10:19 GMT
Yes, Qt will use C++17 if it's available (when building Qt itself). I've fixed that in the Qt 5.9 branch upstream, so it's no longer an issue.

I *think* llvm/clang doesn't compile too, but that might have been my mistake and unrelated to this. Will double check.
Comment by Szymon Strojniak (sstro) - Wednesday, 28 June 2017, 09:52 GMT
Lack of this language feature is painful in case of toolsets based on clang.
You can compile C++17 projects just fine in GCC (I can live with that ;), but developing them with completion and static analysis based on clang can yield many errors.
Comment by Renato Utsch (RenatoUtsch) - Friday, 25 August 2017, 17:06 GMT
By the way, as a quick workaround on your system until a new clang version is released, it seems that by *deleting* the offending line in the <optional> header (line 1032) nothing breaks and everything works as expected (at least everything I've used from the <optional> header so far does).
Comment by Andre K. (Spide) - Sunday, 27 August 2017, 18:41 GMT
Uh, severity low? It breaks my whole build system, now I have to migrate to another compiler? Maybe another distro where C++17 and clang is working! -.-

Loading...