[cfe-dev] [libc++] gets removed from C11

Howard Hinnant hhinnant at apple.com
Mon Jul 1 16:10:26 PDT 2013


On Jul 1, 2013, at 1:56 AM, Richard Smith <richard at metafoo.co.uk> wrote:

> On Sun, Jun 30, 2013 at 2:07 PM, Howard Hinnant <hhinnant at apple.com> wrote:
>> Please review the enclosed patch which guards against the removal of gets from <stdio.h> in C11 and addresses:
>> 
>> http://llvm.org/bugs/show_bug.cgi?id=16369
>> 
>> The current patch is known to be correct only on __APPLE__.  I need help from those testing libc++ on other platforms.  Specifically, <__config> now has:
>> 
>> +#ifdef __APPLE__
>> +#define _LIBCPP_HAS_GETS
>> +#endif
>> 
>> which causes <cstdio> to expose gets:
>> 
>> +#ifdef _LIBCPP_HAS_GETS
>> using ::gets;
>> +#endif
>> 
>> I need to know what other platforms (and possibly under what circumstances) should define _LIBCPP_HAS_GETS.  Patches to <__config> in reply to this request for a review are welcome.  It would be nice to not break others when checking in the fix for http://llvm.org/bugs/show_bug.cgi?id=16369.
> 
> I wonder if this approach is backwards. A <stdio.h> should provide
> gets unless it's in C11 mode. No C++ mode is C11, so if the
> implementation fails to provide gets in C++, then it's broken. Perhaps
> we should blacklist the broken implementations instead of whitelist
> the known-working ones?

Consider this:  Ultimately, the fewer customization flags the better.  And eventually gets() will disappear everywhere. When that happens, use of _LIBCPP_HAS_GETS will disappear too, and so it can be removed since no platform will be defining it.

As each platform drops gets(), and thus stops defining _LIBCPP_HAS_GETS, we will discover at that time if any clients on that platform have been testing _LIBCPP_HAS_GETS and actually need it to be defined.  Each platform can deal with that as part of their plan on removing gets().

If we reverse the flag, _LIBCPP_DOES_NOT_HAVE_GETS will be used by everyone  when gets() disappears everywhere.  This will make it harder to remove from libc++ because since every platform uses it, every platform's clients could also be testing against _LIBCPP_DOES_NOT_HAVE_GETS.

Howard




More information about the cfe-dev mailing list