bug-gnu-libiconv
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [bug-gnu-libiconv] Cannot assume that "gets" is declared


From: Pascal Cuoq
Subject: Re: [bug-gnu-libiconv] Cannot assume that "gets" is declared
Date: Tue, 9 Aug 2016 16:10:27 +0000

On 08 Aug 2016, at 21:44, Dennis Clarke <address@hidden> wrote:

> On 08/08/2016 01:32 PM, Erik Schnetter wrote:
>> The file “stdio.in.h” of libiconv contains these lines:
>> 
>> /* It is very rare that the developer ever has full control of stdin,
>>   so any use of gets warrants an unconditional warning.  Assume it is
>>   always declared, since it is required by C89.  */
>> _GL_WARN_ON_USE (gets, "gets is a security hole - use fgets instead");
>> 
>> This is wrong. “gets” is not part of C11 any more, and hence is not
> > declared on some systems when e.g. the gcc flag “-std=c11” is used.
> > This breaks my build; I have to manually remove these lines.
> 
> Try -std=c99 or -std=iso9899:1999 however know that neither is really
> fully implemented in GCC anyways.
> 
> See https://gcc.gnu.org/onlinedocs/gcc/Standards.html
> 
> regardless of pedanty, yes, those lines are annoying.


While we are being pedantic, note that a C11 compiler is required to define 
__STDC_VERSION__ to 201112L:
http://port70.net/~nsz/c/c11/n1570.html#6.10.8.1

Both Clang and GCC define it despite any minor flaws in their implementations 
of that standard (it would be an additional flaw not to define it anyway):
https://godbolt.org/g/sCE3L9

Guarding the annoying line with pre-processor conditional that test whether 
__STDC_VERSION__ is defined and subsequently whether it is at least 201112L 
should be as simple as:

#ifdef __STDC_VERSION__
#if (__STDC_VERSION__ >= 201112L)

#endif
#endif

(untested, discussion here among other places: 
http://stackoverflow.com/questions/11805636/how-do-i-check-by-using-stdc-version-if-is-std-c1x-in-use
 )


reply via email to

[Prev in Thread] Current Thread [Next in Thread]