<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Oct 11, 2017 at 6:30 PM, David Jones via cfe-dev <span dir="ltr"><<a href="mailto:cfe-dev@lists.llvm.org" target="_blank">cfe-dev@lists.llvm.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Hello,<div><br></div><div>I'm currently working on migrating a large (100M+ LOC) C++ codebase to libc++. One particular pain point are the absence of constexpr constructors for std::pair, std::array, and std::tuple under C++11. </div></div></blockquote><div><br></div><div>Nit: std::array shouldn't have any constructors. But the other members are conditionally constexpr.</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div>Some older versions of libstdc++ expose constexpr constructors under C++11, while libc++ does not; this causes build failures when using libc++.</div></div></blockquote><div><br></div><div>Hmm, just to clarify, it's not just older versions of libstdc++ that do this, but newer ones as well. It's not like they removed it later.</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div><br></div><div>I would like to add a configuration variable that enables the constexpr qualifier on these constructors for C++11 or later, with the intent of advancing the C++ version as quickly as possible. Most of the uses can be trivially replaced by removing constexpr or switching to arrays, but this is churn for code which will (hopefully) soon be compliant anyhow.</div></div></blockquote><div><br></div><div>I'm actually quite sympathetic to enabling this extension by default, since MSVC and libstdc++ both seem to. We're the odd man out.</div><div>If everybody else can safely get away with this, we should be able to as well.</div><div><br></div><div>BTW, by "C++11 or later" you mean "C++11" because they're already required to be constexpr in C++14.</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div><br></div><div>I suspect this may be useful for other codebases that build in C++11 mode to move to libc++... however, this would be a non-conforming extension. Adding a configuration option in __<a href="http://config_site.in" target="_blank">config_site.in</a> (with the default being conforming behaviour) seems like it may be the most reasonable way to add the option.</div></div></blockquote><div><br></div><div>The extension is technically slightly worse than non-conforming; it's explicitly forbidden. Implementations are not allowed to apply constexpr where it isn't specified. However I think this rule should be relaxed to allow implementations to backport newly added constexpr specifiers to older dialects as an extension, as is this case.</div><div><br></div><div>However my main concern with this as an on-by-default extension is that it has the potential to break code. There are certain constexpr evaluations that might result in a hard compile error that wouldn't before. I think Clang has fixed most of these cases though.</div><div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div><br></div><div>Please let me know if there are any strong objections to this plan.</div><div><br></div><div>Thanks,</div><div>--dlj</div></div>
<br>______________________________<wbr>_________________<br>
cfe-dev mailing list<br>
<a href="mailto:cfe-dev@lists.llvm.org">cfe-dev@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/<wbr>mailman/listinfo/cfe-dev</a><br>
<br></blockquote></div><br></div></div>