<div dir="ltr"><div dir="ltr"></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Sun, 4 Aug 2019 at 00:37, Eric Fiselier <<a href="mailto:eric@efcs.ca">eric@efcs.ca</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div dir="ltr"><br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Sat, Aug 3, 2019 at 10:14 AM Arthur O'Dwyer via cfe-dev <<a href="mailto:cfe-dev@lists.llvm.org" target="_blank">cfe-dev@lists.llvm.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div dir="ltr"><div dir="ltr">On Sat, Aug 3, 2019 at 6:03 AM JVApen via cfe-dev <<a href="mailto:cfe-dev@lists.llvm.org" target="_blank">cfe-dev@lists.llvm.org</a>> wrote:<br></div><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div style="font-family:verdana,sans-serif;font-size:small;color:rgb(0,0,0)">Hello all,<br></div><div style="font-family:verdana,sans-serif;font-size:small;color:rgb(0,0,0)"><br></div><div style="font-family:verdana,sans-serif;font-size:small;color:rgb(0,0,0)">I'm currently testing 9.0.0 and I'm one of those strange people that uses -Weverything in production, as we only support a single clang-release at the same time. (Actually clang-cl, as it's Windows-only)<br></div><div style="font-family:verdana,sans-serif;font-size:small;color:rgb(0,0,0)">During the upgrade, I've noticed a new warning "-Wctad-maybe-unsupported".<br></div><div style="font-family:verdana,sans-serif;font-size:small;color:rgb(0,0,0)">At first, I was really happy seeing it and started updating some code that implicitly used it.</div><div style="font-family:verdana,sans-serif;font-size:small;color:rgb(0,0,0)">I'm even considering to propose an extension to our styleguide, as mentioned in the review of the warning: <a href="https://reviews.llvm.org/D56731" target="_blank">https://reviews.llvm.org/D56731</a></div><div style="font-family:verdana,sans-serif;font-size:small;color:rgb(0,0,0)">`Some style guides want to allow using CTAD only on types that "opt-in"`<br></div><div><br></div><div><div style="font-family:verdana,sans-serif;font-size:small;color:rgb(0,0,0)">However, after finishing my initial testing and applying some suppression and update locally, I'm changing my mind.<br></div><div style="font-family:verdana,sans-serif;font-size:small;color:rgb(0,0,0)">Over half of the updates I had to do were about `std::unique_lock`, `std::scope_guard` ... (and this without actively using this feature).<br></div></div></div></blockquote></div></div></div></blockquote><div><br></div><div>What do you mean by "without actively using this feature"?</div></div></div></blockquote><div><br></div><div><div style="font-family:verdana,sans-serif;font-size:small;color:rgb(0,0,0)" class="gmail_default">We presented the use of C++17 when we enabled it, we never mentioned CTAD, so the only users of it are either the few programmers who actually know about it or accidental usages.</div></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div class="gmail_quote"><div>It is unfortunate that this warning will flag types designed to work with CTAD, but who don't need any explicit deduction guides.</div><div>Over time, I hope libraries that care about CTAD will address this by suppressing the warning manually; but that's not an ideal solution.</div><div><div><br></div></div><div> <br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div dir="ltr"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div><div style="font-family:verdana,sans-serif;font-size:small;color:rgb(0,0,0)"></div><div style="font-family:verdana,sans-serif;font-size:small;color:rgb(0,0,0)">These classes, if I'm correct, are one of the selling point of CTAD and are prohibited thanks to this warning.</div></div></div></blockquote></div></div></div></blockquote><div><br></div><div>They're not meant to be triggered by this warning. It's just an oversight.</div><div><br></div><div>I'll update and audit libc++ to opt-in where needed. I'll also set up libc++'s test suite to build with this warning</div><div>enabled.</div><div><br></div><div>I'll try to get the fixed into 9.0.</div></div></div></blockquote><div><br></div><div><div style="font-family:verdana,sans-serif;font-size:small;color:rgb(0,0,0)" class="gmail_default">I wasn't very explicit about this, however, we only use clang-cl with the MSVC headers. So from my point of view, it ain't that urgent. Although it technically being undefined behavior, we can write such a header as well and include it in our precompiled header (<a href="https://docs.microsoft.com/en-us/cpp/build/reference/fi-name-forced-include-file?view=vs-2019">/FI</a>).</div><div style="font-family:verdana,sans-serif;font-size:small;color:rgb(0,0,0)" class="gmail_default">Just wondering, is it allowed for the standard library implementation to add these deduction guides without them being specified in the standard? (I presume yes, as behavior doesn't change and one can't detect if this deduction guide exists)<br></div></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div class="gmail_quote"><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div dir="ltr"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div><div style="font-family:verdana,sans-serif;font-size:small;color:rgb(0,0,0)"><br></div><div style="font-family:verdana,sans-serif;font-size:small;color:rgb(0,0,0)">To circle back to title of the email, should -Wctad-maybe-unsupported actually be a compiler warning iso a clang-tidy check?<br></div></div></div></blockquote><div><br></div><div>(You mean "should -Wctad-maybe-unsupported be a clang-tidy check instead of a compiler warning?", I assume.)</div></div></div></div></blockquote></div></div></blockquote><div><span class="gmail_default" style="font-family:verdana,sans-serif;font-size:small;color:rgb(0,0,0)">Yes, indeed. My bad.</span> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div dir="ltr"><div class="gmail_quote"><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div><div style="font-family:verdana,sans-serif;font-size:small;color:rgb(0,0,0)">If so, would it make sense of having a white-list, like all `std::` classes?<br></div></div></div></blockquote></div></div></div></blockquote><div><br></div><div>The diagnostic is no less valid for types in the standard library. The library author should audit the type to ensure it's CTAD safe, write tests, and then explicitly opt it in. This is</div><div>important for the correctness of client programs written using CTAD.</div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div dir="ltr"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div><div style="font-family:verdana,sans-serif;font-size:small;color:rgb(0,0,0)"></div></div></div></blockquote><div><br></div><div>FWIW, I continue to believe that it makes no sense to talk about the <i><b>library author</b></i> "opting in" to CTAD.</div></div></div></div></blockquote><div><br></div><div>Types have to be designed with CTAD in mine. Without explicit deduction guides CTAD often does the wrong thing.</div><div>Even otherwise unobservable qualities about how a constructor is lexically spelled in source can greatly impact CTAD.</div><div>Whether a template was designed to support CTAD is an important quality we should talk more about.</div><div><br></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div dir="ltr"><div class="gmail_quote"><div>Either the <i><b>client programmer</b></i> trusts CTAD (even if it runs the risk of deducing the wrong thing sometimes) and thus every set-of-missing-angle-brackets must be assumed to be intentional no matter what type it's on, or else the client programmer doesn't trust CTAD (because of the aforementioned risk), and thus every set-of-missing-angle-brackets must be assumed to be unintentional.</div></div></div></div></blockquote><div><br></div><div>This isn't a dichotomy.</div><div><br></div><div>To be clear, "-Wctad-maybe-unsupported" diagnoses only usages of CTAD on types without any explicit deduction guides.</div><div><br></div><div>  </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div dir="ltr"><div class="gmail_quote"><div>The intentions of the <i><b>library author</b></i> don't matter at all in this equation.</div></div></div></div></blockquote><div><br></div></div></div></blockquote><div><div style="font-family:verdana,sans-serif;font-size:small;color:rgb(0,0,0)" class="gmail_default"></div></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div class="gmail_quote"><div></div><div>Whether a type was designed with knowledge of CTAD in mind has a causal relationship with the correctness of usages of that type with CTAD.</div><div>As client programmer I don't want to use CTAD on types that haven't been changed since before CTAD was a feature.</div></div></div></blockquote><div><span class="gmail_default" style="font-family:verdana,sans-serif;font-size:small;color:rgb(0,0,0)"></span></div><div><span class="gmail_default" style="font-family:verdana,sans-serif;font-size:small;color:rgb(0,0,0)">Agreed!</span> </div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div class="gmail_quote"><div></div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div dir="ltr"><div class="gmail_quote"><div><br></div><div>The situation for me is exactly analogous to VLAs in C — including the shape of the workaround: "write an explicit call to malloc()" versus "write an explicit call to make_foo()".</div><div><a href="https://reviews.llvm.org/D54565" target="_blank">https://reviews.llvm.org/D54565</a> implements a `-Wctad` warning analogous to `-Wvla`.</div></div></div></div></blockquote></div></div></blockquote><div> </div><div><span class="gmail_default" style="font-family:verdana,sans-serif;font-size:small;color:rgb(0,0,0)">I'm not sure we are talking about the same thing here, from what I read in that review, it flags all usages of CTAD. While the warning I mentioned doesn't trigger if the deduction guide exists. Although both use-cases are relevant, I'm in the luxurious position of having a single C++ standard to work with (and worry about). </span> <br></div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div dir="ltr"><div class="gmail_quote"><div></div><div>–Arthur</div></div></div></div>
_______________________________________________<br>
cfe-dev mailing list<br>
<a href="mailto:cfe-dev@lists.llvm.org" target="_blank">cfe-dev@lists.llvm.org</a><br>
<a href="https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev" rel="noreferrer" target="_blank">https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev</a><br>
</blockquote></div></div>
</blockquote></div></div>