Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The implicit version tuple's "reduced-arity-initialization" extension breaks conforming code. #27748

Closed
llvmbot opened this issue Apr 15, 2016 · 1 comment
Labels
bugzilla Issues migrated from bugzilla libc++ libc++ C++ Standard Library. Not GNU libstdc++. Not libc++abi.

Comments

@llvmbot
Copy link
Collaborator

llvmbot commented Apr 15, 2016

Bugzilla Link 27374
Resolution FIXED
Resolved on Dec 08, 2016 17:58
Version unspecified
OS All
Reporter LLVM Bugzilla Contributor
CC @mclow

Extended Description

This bug tracks LWG issue #​2419 (http://cplusplus.github.io/LWG/lwg-active.html#2419)

Calls to foo(v) can implicitly construct a n-tuple where n > 1 due to libc++'s tuple extensions. This can cause overload resolution for foo(v) to select a different overload than would otherwise be choosen for a conforming tuple implementation. For example:

#include
#include

struct base
{
void out(const std::tuple<char, char>& w) const
{
std::cerr << "Tuple: " << std::get<0>(w) << std::get<1>(w) << '\n';
}
};

struct decorator
{
base b_;

template <typename... Args>
auto
out(Args&&... args)
-> decltype(b_.out(args...))
{
return b_.out(args...);
}

void out(const char& w)
{
std::cerr << "char: " << w << '\n';
}
};

int main()
{
decorator d{base{}};
char l = 'a';
d.out(l);
}

Libc++'s tuple will cause this program to print "Tuple: a" where it should actually print "char: a".

The fix for this problem is to remove the extension on the implicit version of the UTypes... constructors.

@llvmbot
Copy link
Collaborator Author

llvmbot commented Dec 9, 2016

Fixed in r289158 by disabling the extension on the implicit constructors. To support existing users of the extension it can be re-enabled using a macro.

@llvmbot llvmbot transferred this issue from llvm/llvm-bugzilla-archive Dec 10, 2021
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bugzilla Issues migrated from bugzilla libc++ libc++ C++ Standard Library. Not GNU libstdc++. Not libc++abi.
Projects
None yet
Development

No branches or pull requests

1 participant