Allan Adler wrote:
> Suppose the program is:
> main() { fn1(); if (debug == 0) fn2();}
> where fn2() returns int and fn1() returns int*. Since main is implicitly
> being declared as returning int, is there a possible problem here? If
> debug does equal 0, then the last thing to execute is fn2, which returns
> the expected int. If debug does not equal 0, then the last thing to
execute
> is fn1() which returns an unexpected int*.
>
> I am describing a simplification of a piece of code I am reading by
someone
> else.
C99 outlawed 'implicit int' - but most compilers still allow it except
in a strict C99 compliance mode.
All the code is pretty ill-defined. The return value (exit status) from
main is 0 under C99 (section 5.1.2.2.3) since you don't have an explicit
return value. Under C89, the return value is undefined.
Since debug is not declared in this snippet, it won't compile, of
course. Ideally, fn1 and fn2 should also be declared.
But, since nothing uses the return value from fn1(), it probably doesn't
matter that it wasn't declared correctly. If the value was used, then
it would matter that fn1() was not declared correctly.
--
Jonathan Leffler #include <disclaimer.h>
Email: jleffler@[EMAIL PROTECTED]
jleffler@[EMAIL PROTECTED]
of DBD::Informix v2008.0229 -- http://dbi.perl.org/
publictimestamp.org/ptb/PTB-2708 sha224 2008-03-09 00:00:07
05BA542F6B3391EC0006AB13CD57BC18EF6C087A7DA3D02BD54A3F3A
--
comp.lang.c.moderated - moderation address: clcm@[EMAIL PROTECTED]
-- you must
have an appropriate newsgroups line in your header for your mail to be
seen,
or the newsgroup name in square brackets in the subject line. Sorry.


|