This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Undefined functions in C


Hi,

Googling around, you will find many people saying that C99 disallows
undefined functions (e.g [1]), often citing C99 6.5.2.2.  My reading
of this doesn't seem to suggest it disallows undefined functions; in
fact it talks about type promotion rules for undefined functions.

And indeed, even with -std=c99 gcc still only warns about undefined
functions (and assumes they return int, etc), not gives an error.
This is particularly annoying on 64 bit architectures where the top
bits of pointers get stripped when converted to int when people forget
to include the right headers.  A compiler error (yes it warns, but
people often ignore it) rather than a segfault would be more useful.

Can anyone point me to where C99 explicitly disallows a function
without a declaration, and if so why doesn't gcc in C99 mode give an
error rather than falling back to the C89 semantics?  Or are the
numerous people suggesting C99 disallows undefined functions
incorrect?

-i
ianw@gelato.unsw.edu.au
http://www.gelato.unsw.edu.au

[1] http://david.tribble.com/text/cdiffs.htm ("Implicit function declarations")

Attachment: signature.asc
Description: Digital signature


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]