<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Thu, Oct 8, 2015 at 6:58 PM, Richard Smith <span dir="ltr"><<a href="mailto:richard@metafoo.co.uk" target="_blank">richard@metafoo.co.uk</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"><div class="gmail_extra"><div class="gmail_quote"><span class="">On Thu, Oct 8, 2015 at 6:25 PM, Eric Fiselier <span dir="ltr"><<a href="mailto:eric@efcs.ca" target="_blank">eric@efcs.ca</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">Patch #12 needs revision. A bunch of function definitions were moved<br>
out of the std namespace and into the global.<br>
That change is incorrect.</blockquote><div><br></div></span><div>Slightly updated version attached. I should probably explain what's going on here in more detail:</div><div><br></div><div>Per [c.strings]p4-p13, we're supposed to replace C functions of the form</div><div><br></div><div>  char *foo(const char*);</div><div><br></div><div>with a pair of const-correct overloads of the form</div><div><br></div><div>  char *foo(char *);</div><div>  const char *foo(const char*);</div><div><br></div><div>Now, most C standard libraries will do this for us when included in C++ mode (because it's not possible for the C++ library to fix this up after the fact). For the cases where we *don't* believe we have such a considerate C library, we add one declaration to C's overload, to get:</div><div><br></div><div>  char *foo(char*);</div><div>  char *foo(const char*)</div><div><br></div><div>... which doesn't really help much, but is the closest we can get to the right set of declarations. The declarations we add just dispatch to the C declarations.</div><div><br></div><div>These new declarations *should* be in the global namespace when including <string.h>, and it makes sense for us to put them in the global namespace when including <cstring> (otherwise, that header leaves us with a broken overload set in the global namespace, containing just one of the two expected functions).</div><div><br></div><div>Anyway, most of the above is a description of what we did before. What's new here is that we attempt to fix the overload set for both <string.h> and for <cstring>, not just for the latter. At the end of all these changes, you'll see that all that the <cfoo> headers do is to include the <foo.h> header and use using-declarations to pull the names into namespace std; this is no exception to that pattern.</div></div></div></div></blockquote><div><br></div><div>Per Eric and my discussion on IRC, the pattern used by <cwchar> seems better here:</div><div><br></div><div>If libc has left us with a bad overload set, don't try to fix the names in ::, just provide a complete set of overloads in namespace std.</div><div><br></div><div>A patch for that approach is attached.</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 class="gmail_extra"><div class="gmail_quote"><div><div class="h5"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div><div>
On Thu, Oct 8, 2015 at 7:09 PM, Eric Fiselier <<a href="mailto:eric@efcs.ca" target="_blank">eric@efcs.ca</a>> wrote:<br>
> Patch #11 LGTM. Any reason you removed the "#pragma diagnostic ignored<br>
> "-Wnonnull"" in test/std/depr/depr.c.headers/stdlib_h.pass.cpp?<br>
> I would like to leave it in so this test doesn't fail with older clang<br>
> versions.<br>
><br>
> /Eric<br>
><br>
> On Thu, Oct 8, 2015 at 6:47 PM, Eric Fiselier <<a href="mailto:eric@efcs.ca" target="_blank">eric@efcs.ca</a>> wrote:<br>
>> Patch #10 LGTM.<br>
>><br>
>> On Thu, Oct 8, 2015 at 4:28 PM, Richard Smith <<a href="mailto:richard@metafoo.co.uk" target="_blank">richard@metafoo.co.uk</a>> wrote:<br>
>>> On Thu, Oct 8, 2015 at 11:50 AM, Marshall Clow <<a href="mailto:mclow.lists@gmail.com" target="_blank">mclow.lists@gmail.com</a>><br>
>>> wrote:<br>
>>>><br>
>>>> On Tue, Oct 6, 2015 at 3:57 PM, Richard Smith <<a href="mailto:richard@metafoo.co.uk" target="_blank">richard@metafoo.co.uk</a>><br>
>>>> wrote:<br>
>>>>><br>
>>>>> <stddef.h>. This one is tricky:<br>
>>>>><br>
>>>>> 1) There's an (undocumented) interface between the C standard library and<br>
>>>>> this header, where the macros __need_ptrdiff_t, __need_size_t,<br>
>>>>> __need_wchar_t, __need_NULL, __need_wint_t request just a piece of this<br>
>>>>> header rather than the whole thing. If we see any of those, just go straight<br>
>>>>> to the underlying header.<br>
>>>><br>
>>>><br>
>>>> Ok, but in that case we don't get nullptr.  I suspect that's OK.<br>
>>>><br>
>>>>><br>
>>>>> 2) We probably don't want <stddef.h> to include <cstddef> (for<br>
>>>>> consistency with other headers)<br>
>>>><br>
>>>><br>
>>>> No, we do not! :-)<br>
>>>><br>
>>>>><br>
>>>>> , but <stddef.h> must provide a ::nullptr_t (which we don't want<br>
>>>>> <cstddef> to provide). So neither header includes the other. Instead, both<br>
>>>>> include <__nullptr> for std::nullptr_t, and we duplicate the definition of<br>
>>>>> max_align_t between them, in the case where the compiler's <stddef.h><br>
>>>>> doesn't provide it.<br>
>>>>><br>
>>>>> If you prefer, I could make <stddef.h> include <cstddef> to avoid the<br>
>>>>> duplication of the max_align_t logic.<br>
>>>><br>
>>>><br>
>>>> No; this is a minor annoyance, and layer jumping (<stdXXX.h> including<br>
>>>> <cstdXXX>) is a major annoyance - and I'm pretty sure that that would come<br>
>>>> back to bite us in the future.<br>
>>>><br>
>>>> Looks ok to me.<br>
>>><br>
>>><br>
>>> Thanks, everything up to and including patch 09 is now committed.<br>
</div></div></blockquote></div></div></div><br></div></div>
</blockquote></div><br></div></div>