LLVM Bugzilla is read-only and represents the historical archive of all LLVM issues filled before November 26, 2021. Use github to submit LLVM bugs

Bug 27374 - The implicit version tuple's "reduced-arity-initialization" extension breaks conforming code.
Summary: The implicit version tuple's "reduced-arity-initialization" extension breaks ...
Status: RESOLVED FIXED
Alias: None
Product: libc++
Classification: Unclassified
Component: All Bugs (show other bugs)
Version: unspecified
Hardware: PC All
: P normal
Assignee: Eric Fiselier
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-04-15 13:25 PDT by Eric Fiselier
Modified: 2016-12-08 17:58 PST (History)
2 users (show)

See Also:
Fixed By Commit(s):


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Eric Fiselier 2016-04-15 13:25:19 PDT
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 <iostream>
#include <tuple>

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.
Comment 1 Eric Fiselier 2016-12-08 17:58:35 PST
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.