[llvm-bugs] [Bug 27374] New: The implicit version tuple's "reduced-arity-initialization" extension breaks conforming code.

via llvm-bugs llvm-bugs at lists.llvm.org
Fri Apr 15 11:25:19 PDT 2016


            Bug ID: 27374
           Summary: The implicit version tuple's
                    "reduced-arity-initialization" extension breaks
                    conforming code.
           Product: libc++
           Version: unspecified
          Hardware: PC
                OS: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: All Bugs
          Assignee: unassignedclangbugs at nondot.org
          Reporter: eric at efcs.ca
                CC: llvm-bugs at lists.llvm.org, mclow.lists at gmail.com
    Classification: Unclassified

This bug tracks LWG issue #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>
  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';

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.

You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20160415/c18b50f8/attachment.html>

More information about the llvm-bugs mailing list