[llvm-bugs] [Bug 41549] New: CTAD fails to find some defaulted template parameters after first declaration of template

via llvm-bugs llvm-bugs at lists.llvm.org
Sat Apr 20 18:25:46 PDT 2019


https://bugs.llvm.org/show_bug.cgi?id=41549

            Bug ID: 41549
           Summary: CTAD fails to find some defaulted template parameters
                    after first declaration of template
           Product: clang
           Version: trunk
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: -New Bugs
          Assignee: unassignedclangbugs at nondot.org
          Reporter: arthur.j.odwyer at gmail.com
                CC: htmldeveloper at gmail.com, llvm-bugs at lists.llvm.org,
                    neeilans at live.com, richard-llvm at metafoo.co.uk

Reduced from a test case involving class template argument deduction on libc++
unordered_multimap.

// https://godbolt.org/z/X3OqH0
#if FAIL
template <class H, class P> struct umm;
#endif

template <class H = int, class P = int>
struct umm {
    explicit umm(H h = 0, P p = 0);
};

void t() {
    umm m(1);
}

====

$ clang++ -std=c++17 test.cc
(OK)

$ clang++ -std=c++17 test.cc -DFAIL
<source>:11:9: error: no viable constructor or deduction guide for deduction of
template arguments of 'umm'
    umm m(1);
        ^
<source>:7:14: note: candidate template ignored: couldn't infer template
argument 'P'
    explicit umm(H h = 0, P p = 0);
             ^
<source>:2:36: note: candidate template ignored: could not match 'umm<H, P>'
against 'int'
template <class H, class P> struct umm;
                                   ^
1 error generated.

====

GCC, ICC, and MSVC all agree that this code should be considered well-formed:
CTAD should happily take the defaulted value of `P` from the visible
declaration of the primary template, even though that declaration is not the
first declaration in the source file.

-- 
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/20190421/7aded82e/attachment-0001.html>


More information about the llvm-bugs mailing list