<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Sun, Jan 22, 2017 at 6:17 AM, Malcolm Parsons <span dir="ltr"><<a href="mailto:malcolm.parsons@gmail.com" target="_blank">malcolm.parsons@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><span>On 20 January 2017 at 21:32, Nico Weber <<a href="mailto:thakis@chromium.org" target="_blank">thakis@chromium.org</a>> wrote:<br>
> This warns about code like<br>
><br>
>   constexpr int foo = 4;<br>
>   [&foo]() { use(foo); }<br>
><br>
> That's correct, but removing &foo then makes MSVC complain about this code<br>
> like "error C3493: 'foo' cannot be implicitly captured because no default<br>
> capture mode has been specified". A workaround is to make foo static const<br>
> instead of constexpr.<br>
><br>
> This seems like an MSVC bug, but it's still a bit annoying that clang now<br>
> suggests doing things that won't build in other compilers. Any ideas what to<br>
> do about this?<br>
<br>
</span>Should Clang care about the behaviour of other compilers that don't<br>
follow the standard?<br></blockquote><div><br></div><div>clang should be a compiler that people like to use. Multi-platform development isn't super uncommon, so trying to give a good experience in that case seems like a good thing to me -- and we've tried to do that in the past pretty hard. It's possible that "do nothing" is the right thing, but "well that other compiler is buggy" seems like a somewhat oversimplified reply.</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">You could:<br>
Disable the warning on the command line.<br>
Disable the warning with a pragma.<br></blockquote><div><br></div><div>It's an error, not a warning.</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">
Cast foo to void inside the lambda.<br></blockquote><div><br></div><div>That's equivalent to disabling the clang warning in those cases (which would be a shame, since the warning is super useful, and it doesn't introduce problems in most cases -- only with local constexprs). Maybe the warning could be split in two, so that it can be toggled separately for constexpr?</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">
Only capture foo when building with MSVC.</blockquote><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
Stop building with MSVC.<br></blockquote><div><br></div><div>This reply like this make me believe you think it was silly to even report this problem. I don't think it's silly, and there's ample precedent in clang to make it work well in the actual world instead of in a world we wished we lived in.<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">
Complain to Microsoft.<br></blockquote><div><br></div><div>Already done. The reality is that their shipping compiler produces this diagnostic, and the current 2017 build does too.<br></div></div></div></div>