Bug 1459393

Summary: clang fails with -std=c++17 or -std=c++1z on programs that use <future>
Product: [Fedora] Fedora Reporter: Eric Hopper <eric-bugs>
Component: gccAssignee: Jonathan Wakely <jwakely>
Status: CLOSED NEXTRELEASE QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 26CC: davejohansen, fweimer, jakub, jwakely, law, mnewsome, mpolacek, tstellar
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2018-03-14 13:42:30 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 Eric Hopper 2017-06-07 03:12:11 UTC
Description of problem:
This small program fails to compile

------small.cpp------
#include <future>

int main()
{
   return 0;clang-4.0.0-3.fc26.x86_64
}
---------------------

with clang++ -std=c++1z small.cpp
or clang++ -std=c++1z small.cpp

Version-Release number of selected component (if applicable):

libstdc++-devel-7.1.1-2.fc26.x86_64
clang-4.0.0-3.fc26.x86_64

How reproducible:

Every time.

Steps to Reproduce:
1.Create small.cpp
2.Do clang++ -std=c++17 small.cpp
3.Observe the resulting errors

Actual results:

In file included from small.cpp:1:
In file included from /usr/bin/../lib/gcc/x86_64-redhat-linux/7/../../../../include/c++/7/future:38:
/usr/bin/../lib/gcc/x86_64-redhat-linux/7/../../../../include/c++/7/mutex:672:4: error: 
      no matching function for call to '__invoke'
          std::__invoke(std::forward<_Callable>(__f),
          ^~~~~~~~~~~~~
/usr/bin/../lib/gcc/x86_64-redhat-linux/7/../../../../include/c++/7/future:401:2: note: 
      in instantiation of function template specialization 'std::call_once<void
      (std::__future_base::_State_baseV2::*)(std::function<std::unique_ptr<std::__future_base::_Result_base,
      std::__future_base::_Result_base::_Deleter> ()> *, bool *),
      std::__future_base::_State_baseV2 *,
      std::function<std::unique_ptr<std::__future_base::_Result_base,
      std::__future_base::_Result_base::_Deleter> ()> *, bool *>' requested here
        call_once(_M_once, &_State_baseV2::_M_do_set, this,
        ^
/usr/bin/../lib/gcc/x86_64-redhat-linux/7/../../../../include/c++/7/bits/invoke.h:89:5: note: 
      candidate template ignored: substitution failure [with _Callable = void
      (std::__future_base::_State_baseV2::*)(std::function<std::unique_ptr<std::__future_base::_Result_base,
      std::__future_base::_Result_base::_Deleter> ()> *, bool *), _Args =
      <std::__future_base::_State_baseV2 *,
      std::function<std::unique_ptr<std::__future_base::_Result_base,
      std::__future_base::_Result_base::_Deleter> ()> *, bool *>]: no type named
      'type' in 'std::__invoke_result<void
      (std::__future_base::_State_baseV2::*)(std::function<std::unique_ptr<std::__future_base::_Result_base,
      std::__future_base::_Result_base::_Deleter> ()> *, bool *),
      std::__future_base::_State_baseV2 *,
      std::function<std::unique_ptr<std::__future_base::_Result_base,
      std::__future_base::_Result_base::_Deleter> ()> *, bool *>'
    __invoke(_Callable&& __fn, _Args&&... __args)
    ^
In file included from small.cpp:1:
In file included from /usr/bin/../lib/gcc/x86_64-redhat-linux/7/../../../../include/c++/7/future:38:
/usr/bin/../lib/gcc/x86_64-redhat-linux/7/../../../../include/c++/7/mutex:672:4: error: 
      no matching function for call to '__invoke'
          std::__invoke(std::forward<_Callable>(__f),
          ^~~~~~~~~~~~~
/usr/bin/../lib/gcc/x86_64-redhat-linux/7/../../../../include/c++/7/future:1646:27: note: 
      in instantiation of function template specialization 'std::call_once<void
      (std::thread::*)(), std::thread *>' requested here
    void _M_join() { std::call_once(_M_once, &thread::join, &_M_thread); }
                          ^
/usr/bin/../lib/gcc/x86_64-redhat-linux/7/../../../../include/c++/7/bits/invoke.h:89:5: note: 
      candidate template ignored: substitution failure [with _Callable = void
      (std::thread::*)(), _Args = <std::thread *>]: no type named 'type' in
      'std::__invoke_result<void (std::thread::*)(), std::thread *>'
    __invoke(_Callable&& __fn, _Args&&... __args)
    ^
2 errors generated.


Expected results:

A nice a.out file that does nothing

Comment 2 Jonathan Wakely 2017-06-07 14:02:02 UTC
We should consider removing the libstdc++so7 component in bugzilla, it just confuses users. This has nothing to do with libstdc++so7.

Comment 3 Jonathan Wakely 2017-06-07 15:33:16 UTC
Clang doesn't support the GNU extension that libstdc++ relies on for deducing noexcept on a function type, which is https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80690 and reported to Clang as https://bugs.llvm.org/show_bug.cgi?id=32974

Comment 4 Eric Hopper 2017-06-07 20:03:37 UTC
What is the right component to report this against then?

Comment 5 Eric Hopper 2017-06-07 20:04:07 UTC
Oh, sorry, nevermind. I missed the component switching to gcc.

Comment 6 Tom Stellard 2018-03-14 13:42:30 UTC
This was fixed upstream in clang by r304946, which first appeared in the 5.0 release.  This patch is too big to backport to 4.0, so you will need to upgrade to f27 if you want a fix for this bug.