Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.c > #149818
| Path | csiph.com!eternal-september.org!feeder.eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail |
|---|---|
| From | Keith Thompson <Keith.S.Thompson+u@gmail.com> |
| Newsgroups | comp.lang.c |
| Subject | Re: Puzzling "implicit declaration" Warning |
| Date | Fri, 07 Feb 2020 02:12:41 -0800 |
| Organization | None to speak of |
| Lines | 37 |
| Message-ID | <87imki1zae.fsf@nosuchdomain.example.com> (permalink) |
| References | <WsmdnVL9ioPMhaDDnZ2dnUU7_83NnZ2d@giganews.com> <slrnr3q9cl.km3.grahn+nntp@frailea.sa.invalid> |
| Mime-Version | 1.0 |
| Content-Type | text/plain |
| Injection-Info | reader02.eternal-september.org; posting-host="54fe45f179ce1a7a1c5c825e40bf38d7"; logging-data="1918"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18wNUTnJJ8EYqDFVOFyCApr" |
| User-Agent | Gnus/5.13 (Gnus v5.13) Emacs/26.3 (gnu/linux) |
| Cancel-Lock | sha1:yZHhuP38mEkJ2nUJVoUuhusloMM= sha1:dN8SEIbdtpgRcQCOJ02G6VV+tL8= |
| Xref | csiph.com comp.lang.c:149818 |
Show key headers only | View raw
Jorgen Grahn <grahn+nntp@snipabacken.se> writes:
> On Fri, 2020-02-07, Robbie Hatley wrote:
[...]
>> And yet, the program works, so obviously Gnu extensions are being
>> properly compiled.
>
> I'm not sure it really works; the warning means the compiler will
> assume the prototype is 'int exp10()'. Then at the linking stage
> there is no additional type checking and no protection against GNU
> extensions, so it will link ok.
>
> I don't know offhand what happens when you get the prototype wrong,
> but it's a bad thing and I make sure it never happens. (Others will
> be able to tell you.)
What happens is undefined behavior.
If you examine your math.h header, I think you'll find that the
declaration of exp10 isn't made visible unless _GNU_SOURCE has been
defined.
Under C90 rules, the behavior would be well defined *if* the function
returned an int result and expected an argument of the type you actually
gave it. Under C99 and later, calling a function with no visible
declaration is a constraint violation (and if the required diagnostic is
a non-fatal warning, the behavior is undefined).
With a simpler example, compiling with gcc yields (after a couple of
warnings) a program that behaves as if the declaration were visible, but
clang doesn't. One of the warnings from gcc indicates that it treats
exp10 as a built-in function, so it's not too surprising that it's able
to generate a "correct" call.
--
Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com
Working, but not speaking, for Philips Healthcare
void Void(void) { Void(); } /* The recursive call of the void */
Back to comp.lang.c | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Puzzling "implicit declaration" Warning Robbie Hatley <see.my.signature@for.my.contact.info> - 2020-02-06 23:57 -0800
Re: Puzzling "implicit declaration" Warning Jorgen Grahn <grahn+nntp@snipabacken.se> - 2020-02-07 08:53 +0000
Re: Puzzling "implicit declaration" Warning Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2020-02-07 02:12 -0800
Re: Puzzling "implicit declaration" Warning Robbie Hatley <see.my.signature@for.my.contact.info> - 2020-02-08 01:53 -0800
Re: Puzzling "implicit declaration" Warning Ben Bacarisse <ben.usenet@bsb.me.uk> - 2020-02-08 12:59 +0000
Re: Puzzling "implicit declaration" Warning Manfred <noname@invalid.add> - 2020-02-08 17:21 +0100
Re: Puzzling "implicit declaration" Warning Manfred <noname@invalid.add> - 2020-02-08 17:34 +0100
Re: Puzzling "implicit declaration" Warning Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2020-02-08 14:37 -0800
Re: Puzzling "implicit declaration" Warning scott@slp53.sl.home (Scott Lurndal) - 2020-02-08 18:39 +0000
Re: Puzzling "implicit declaration" Warning Robbie Hatley <see.my.signature@for.my.contact.info> - 2020-02-08 01:15 -0800
Re: Puzzling "implicit declaration" Warning chad <cdalten@gmail.com> - 2020-02-08 05:05 -0800
Re: Puzzling "implicit declaration" Warning Bart <bc@freeuk.com> - 2020-02-08 14:05 +0000
Re: Puzzling "implicit declaration" Warning Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2020-02-08 14:35 -0800
Re: Puzzling "implicit declaration" Warning Bart <bc@freeuk.com> - 2020-02-08 22:39 +0000
Re: Puzzling "implicit declaration" Warning Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2020-02-08 15:30 -0800
Re: Puzzling "implicit declaration" Warning David Brown <david.brown@hesbynett.no> - 2020-02-09 12:24 +0100
Re: Puzzling "implicit declaration" Warning Robbie Hatley <see.my.signature@for.my.contact.info> - 2020-02-09 23:42 -0800
Re: Puzzling "implicit declaration" Warning chad <cdalten@gmail.com> - 2020-02-10 05:34 -0800
Re: Puzzling "implicit declaration" Warning Ben Bacarisse <ben.usenet@bsb.me.uk> - 2020-02-10 16:12 +0000
Re: Puzzling "implicit declaration" Warning Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2020-02-10 11:14 -0800
Re: Puzzling "implicit declaration" Warning Jorgen Grahn <grahn+nntp@snipabacken.se> - 2020-02-11 07:06 +0000
Re: puzzling enragement by innocuous variable names Robbie Hatley <see.my.signature@for.my.contact.info> - 2020-09-10 19:47 -0700
Re: puzzling enragement by innocuous variable names Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2020-09-10 20:28 -0700
Re: puzzling enragement by innocuous variable names Peter 'Shaggy' Haywood <phaywood@alphalink.com.au> - 2020-09-13 14:57 +1000
Re: puzzling enragement by innocuous variable names gazelle@shell.xmission.com (Kenny McCormack) - 2020-09-15 17:58 +0000
Re: puzzling enragement by innocuous variable names Joe Pfeiffer <pfeiffer@cs.nmsu.edu> - 2020-09-14 09:38 -0600
Re: Puzzling "implicit declaration" Warning James Kuyper <jameskuyper@alumni.caltech.edu> - 2020-02-11 00:21 -0500
Re: Puzzling "implicit declaration" Warning Les Cargill <lcargill99@comcast.com> - 2020-02-08 17:00 -0600
Re: Puzzling "implicit declaration" Warning Robbie Hatley <see.my.signature@for.my.contact.info> - 2020-02-09 22:50 -0800
Re: Puzzling "implicit declaration" Warning Ben Bacarisse <ben.usenet@bsb.me.uk> - 2020-02-10 16:00 +0000
Re: Puzzling "implicit declaration" Warning scott@slp53.sl.home (Scott Lurndal) - 2020-02-10 16:28 +0000
Re: Puzzling "implicit declaration" Warning Ben Bacarisse <ben.usenet@bsb.me.uk> - 2020-02-10 16:42 +0000
csiph-web