Bug 1485643

Summary: Clang fails on std::optional
Product: [Fedora] Fedora Reporter: Georg Sauthoff <fedora>
Component: clangAssignee: Dave Airlie <airlied>
Status: CLOSED CURRENTRELEASE QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 27CC: airlied, davejohansen, plroskin, sbergman, siddharth.kde, tstellar
Target Milestone: ---   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2018-01-16 00:12:42 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

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.