[TUHS] : C dialects (was: I can't drive 55: "GOTO considered harmful" 55th anniversary)
Dan Cross
crossd at gmail.com
Tue Mar 14 10:23:10 AEST 2023
On Mon, Mar 13, 2023 at 6:47 PM Dave Horsfall <dave at horsfall.org> wrote:
>
> On Tue, 14 Mar 2023, Dave Horsfall followed himself up:
>
> > Trivia: I think it was OpenBSD that nobbled gets() to print a warning
> > whenever it was invoked :-)
>
> FreeBSD 10.4 (old, I know):
>
> c.c:1:1: warning: type specifier missing, defaults to 'int' [-Wimplicit-int] main()
> ^~~~
> c.c:2:3: warning: implicit declaration of function 'gets' is invalid in C99
> [-Wimplicit-function-declaration]
> { gets(); }
> ^
> 2 warnings generated.
> /tmp/c-36bc21.o: In function `main':
> c.c:(.text+0x4): warning: warning: this program uses gets(), which is unsafe.
> aneurin% ./c
> warning: this program uses gets(), which is unsafe.
> <CR>
> aneurin%
>
> On the MacBook (10.13.6 High Sierra):
>
> c.c:1:1: warning: type specifier missing, defaults to 'int' [-Wimplicit-int]
> main()
> ^
> c.c:2:3: warning: implicit declaration of function 'gets' is invalid in C99
> [-Wimplicit-function-declaration]
> { gets(); }
> ^
> 2 warnings generated.
> mackie:tmp dave$ ./c
> warning: this program uses gets(), which is unsafe.
> <CR>
>
> And it core-dumped,,,
I should hope so! It takes a pointer to a buffer as an argument, and
it appears you elided that. :-D
> (I don't have access to my Penguin/OS lapdog right now.)
>
> I think that it's trying to tel me something :-)
gets: unsafe at any C.
- Dan C.
More information about the TUHS
mailing list