llvm / llvm-project

The LLVM Project is a collection of modular and reusable compiler and toolchain technologies.
http://llvm.org
Other
29.36k stars 12.14k forks source link

tuple's "TupleLike" constructors behave slightly differently than standard versions #27749

Closed llvmbot closed 3 years ago

llvmbot commented 8 years ago
Bugzilla Link 27375
Resolution FIXED
Resolved on Jun 08, 2021 08:42
Version unspecified
OS All
Reporter LLVM Bugzilla Contributor
CC @ldionne,@mclow

Extended Description

Libc++ implements the two standard constructors 1) 'tuple(tuple const&)' and 2) 'tuple(tuple&&)' as a single generic overload 'tuple(Tuple&&)'. This can cause a slight differences in overload resolution.

For example the call to 'tuple(tuple<...>{})' will first consider ctor #​2. However if this constructor SFINAE's aware then ctor #​1 should be considered. Since libc++ only provides a single overload it will only consider #​2. This breaks the following code:

std::tuple<int&>(std::tuple<int&&>(42));

ldionne commented 3 years ago

This is fixed since Clang 9. I don't have the specific commit, but I reproduced on godbolt:

Clang 8 (fails): https://godbolt.org/z/Eh67c6fPM Clang 9 (works): https://godbolt.org/z/jo9s1bPxW