Bug 1485643 - Clang fails on std::optional
Summary: Clang fails on std::optional
Keywords:
Status: CLOSED CURRENTRELEASE
Alias: None
Product: Fedora
Classification: Fedora
Component: clang
Version: 27
Hardware: All
OS: Linux
unspecified
unspecified
Target Milestone: ---
Assignee: Dave Airlie
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2017-08-26 15:16 UTC by Georg Sauthoff
Modified: 2018-01-16 00:13 UTC (History)
6 users (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2018-01-16 00:12:42 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
LLVM 33117 0 None None None 2017-08-28 19:00:21 UTC

Description Georg Sauthoff 2017-08-26 15:16:39 UTC
Description of problem:
Compiling a C++ program that includes <optional> yields a compile error with clang++.


Version-Release number of selected component (if applicable):
clang-4.0.0-3.fc26.x86_64

How reproducible:
always

Steps to Reproduce:
1. $ cat > test_optional.cc 
#include <optional>
int main()
{
  return 0;
}
2. clang++ -std=c++1z test_optional.cc
3.

Actual results:
In file included from test_optional.cc:1:
/usr/bin/../lib/gcc/x86_64-redhat-linux/7/../../../../include/c++/7/optional:1032:27: error: use of class template 'optional' requires template arguments
  template <typename _Tp> optional(_Tp) -> optional<_Tp>;
                          ^
/usr/bin/../lib/gcc/x86_64-redhat-linux/7/../../../../include/c++/7/optional:451:11: note: template is declared here
    class optional
          ^
/usr/bin/../lib/gcc/x86_64-redhat-linux/7/../../../../include/c++/7/optional:1032:40: error: expected ';' at end of declaration
  template <typename _Tp> optional(_Tp) -> optional<_Tp>;
                                       ^
/usr/bin/../lib/gcc/x86_64-redhat-linux/7/../../../../include/c++/7/optional:1032:41: error: cannot use arrow operator on a type
  template <typename _Tp> optional(_Tp) -> optional<_Tp>;
                                        ^
3 errors generated.

Expected results:
No compile errors, successful compilation.

Additional info:
It works with g++ as expected:

$ g++ -std=c++1z test_optional.cc

Apparently, the libstdc++ which is also used by Fedora's clang++ implements std::optional in a way that is not (yet) supported by clang.

See also: https://bugs.archlinux.org/index.php?do=details&task_id=54276

Comment 1 Pavel Roskin 2017-12-03 05:15:31 UTC
Fedora 27 is also affected. clang-5 should fix the issue.

Comment 2 Pavel Roskin 2018-01-13 02:31:47 UTC
The issue is resolved in Fedora 27 by clang-5.0.0-1.fc27.x86_64

I don't see a clang 5 update for Fedora 26 at this time: https://koji.fedoraproject.org/koji/packageinfo?packageID=21848

So I'm afraid it's WONTFIX for Fedora 26.

Comment 3 Tom Stellard 2018-01-16 00:13:50 UTC
Fixed in 5.0.0-1.fc27.


Note You need to log in before you can comment on or make changes to this bug.