<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><div class="">+ Gauthier</div><div class=""><br class=""></div>This is the culprit:<div class=""><br class=""></div><div class=""><div class="">commit a27d26e290545ff0686c0d08975baa53b9a4878b</div><div class="">Author: Gauthier Harnisch <<a href="mailto:tyker1@outlook.com" class="">tyker1@outlook.com</a>></div><div class="">Date:   Fri Jun 14 08:40:04 2019 +0000</div><div class=""><br class=""></div><div class="">    [clang] Fixing incorrect implicit deduction guides (PR41549)</div><div class=""><br class=""></div><div class="">    Summary:</div><div class="">    [[ <a href="https://bugs.llvm.org/show_bug.cgi?id=41549" class="">https://bugs.llvm.org/show_bug.cgi?id=41549</a> | bug report ]]</div><div class=""><br class=""></div><div class="">    Before this patch, implicit deduction guides were generated from the first declaration found by lookup.</div><div class="">    With this patch implicit deduction guides are generated from the definition of the class template.</div><div class="">    Also added test that was previously failing.</div><div class=""><br class=""></div><div class="">    Reviewers: rsmith</div><div class=""><br class=""></div><div class="">    Reviewed By: rsmith</div><div class=""><br class=""></div><div class="">    Subscribers: cfe-commits, Quuxplusone</div><div class=""><br class=""></div><div class="">    Tags: #clang</div><div class=""><br class=""></div><div class="">    Differential Revision: <a href="https://reviews.llvm.org/D63072" class="">https://reviews.llvm.org/D63072</a></div><div><br class=""><blockquote type="cite" class=""><div class="">On Jun 17, 2019, at 17:20, Michał Górny <<a href="mailto:mgorny@gentoo.org" class="">mgorny@gentoo.org</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><span style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; float: none; display: inline !important;" class="">On Mon, 2019-06-17 at 17:02 -0400, Louis Dionne wrote:</span><br style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class=""><blockquote type="cite" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; text-decoration: none;" class=""><blockquote type="cite" class="">On Jun 17, 2019, at 15:46, Louis Dionne via libcxx-commits <<a href="mailto:libcxx-commits@lists.llvm.org" class="">libcxx-commits@lists.llvm.org</a>> wrote:<br class=""><br class=""><br class=""><br class=""><blockquote type="cite" class="">On Jun 17, 2019, at 14:50, Michał Górny <<a href="mailto:mgorny@gentoo.org" class="">mgorny@gentoo.org</a>> wrote:<br class=""><br class="">On Mon, 2019-06-17 at 13:49 -0400, Arthur O'Dwyer wrote:<br class=""><blockquote type="cite" class="">On Mon, Jun 17, 2019 at 12:30 PM Michał Górny via Phabricator <<br class=""><a href="mailto:reviews@reviews.llvm.org" class="">reviews@reviews.llvm.org</a>> wrote:<br class=""><br class=""><blockquote type="cite" class="">mgorny added a comment.<br class=""><br class="">Marshall, `std/containers/associative/map/map.cons/deduct_const.pass.cpp`<br class="">test seems to be reliably failing from commit one on both Gentoo Linux and<br class="">NetBSD. Could you please look at the classical example of totally cryptic<br class="">C++ error? ;-)<br class=""><br class=""><br class=""><a href="http://lab.llvm.org:8011/builders/netbsd-amd64/builds/20/steps/run%20unit%20tests/logs/FAIL%3A%20libc%2B%2B%3A%3Adeduct_const.pass.cpp" class="">http://lab.llvm.org:8011/builders/netbsd-amd64/builds/20/steps/run%20unit%20tests/logs/FAIL%3A%20libc%2B%2B%3A%3Adeduct_const.pass.cpp</a><br class=""><br class=""></blockquote><br class="">Well, I can contribute that that's the error that you get when CTAD deduces<br class="">the wrong thing. Here it's looking at lines 98–100 of deduct_const.pass.cpp<br class=""><br class=""> std::map m({ PC{1,1L}, PC{2,2L}, PC{1,1L}, PC{INT_MAX,1L}, PC{3,1L} },<br class="">test_allocator<PC>(0, 45));<br class=""> ASSERT_SAME_TYPE(decltype(m), std::map<int, long, std::less<int>,<br class="">test_allocator<PC>>);<br class=""><br class="">and deducing the correct value_type for `m`, but it's incorrectly thinking<br class="">that `test_allocator<PC>` should be used as the *comparator* type, not<br class="">the *allocator<br class="">*type.  This is surprising/incorrect, because if all is going as expected,<br class="">then CTAD should be considering the deduction guides<br class=""><br class="">template<class _Key, class _Tp, class _Compare = less<typename<br class="">remove_const<_Key>::type>,<br class="">      class _Allocator = allocator<pair<const _Key, _Tp>>,<br class="">      class = typename enable_if<!__is_allocator<_Compare>::value,<br class="">void>::type,<br class="">      class = typename enable_if<__is_allocator<_Allocator>::value,<br class="">void>::type><br class="">map(initializer_list<pair<_Key, _Tp>>, _Compare = _Compare(), _Allocator =<br class="">_Allocator())<br class="">-> map<typename remove_const<_Key>::type, _Tp, _Compare, _Allocator>;<br class=""><br class="">template<class _Key, class _Tp, class _Allocator,<br class="">      class = typename enable_if<__is_allocator<_Allocator>::value,<br class="">void>::type><br class="">map(initializer_list<pair<_Key, _Tp>>, _Allocator)<br class="">-> map<typename remove_const<_Key>::type, _Tp, less<typename<br class="">remove_const<_Key>::type>, _Allocator>;<br class=""><br class="">CTAD should see that the first guide fails substitution because<br class="">__is_allocator<test_allocator<PC>>::value (that is, test_allocator should<br class="">not be taken as the comparator type).<br class="">CTAD should see that the second guide does not fail substitution, so CTAD<br class="">should unambiguously use the second guide.<br class=""><br class="">The test passes on OSX using clang trunk.  I don't see any #ifdefs or<br class="">anything in include/ or in test/support/test_allocator.h that would cause<br class="">different behavior on Linux or NetBSD.  If you try clang trunk on Linux or<br class="">NetBSD, do you see different behavior (versus what you see with clang<br class="">9.0.0)?<br class=""></blockquote><br class="">This is trunk.  On NetBSD, it's tested using a single tree with<br class="">cxx_under_test being pointed to just-built clang.  On Gentoo, I was<br class="">testing out-of-source build against ~same revision of trunk (± delay<br class="">between fetching the two repos separately).<br class=""><br class="">And yes, I'm surprised that Debian buildbots don't hit this.<br class=""></blockquote><br class="">So you're hitting that with Clang trunk? This is not the kind of problem where the platform should matter, only the compiler and the libc++ version. Let me try to reproduce locally.<br class=""></blockquote><br class="">Yes, I can reproduce locally with Clang trunk. I think this isn't showing up in the Linux bots because they use older compilers. This must be something that was introduced recently-ish. I'll bisect.<br class=""><br class=""></blockquote><br style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class=""><span style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; float: none; display: inline !important;" class="">Oh, and I was wondering if everybody had to hack in just-built clang</span><br style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class=""><span style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; float: none; display: inline !important;" class="">like I did ;-).  Thanks for looking into it.</span><br style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class=""><br style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class=""><br style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class=""><span style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; float: none; display: inline !important;" class="">--<span class="Apple-converted-space"> </span></span><br style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class=""><span style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; float: none; display: inline !important;" class="">Best regards,</span><br style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class=""><span style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; float: none; display: inline !important;" class="">Michał Górny</span></div></blockquote></div><br class=""></div></body></html>