Date: Tue, 16 Apr 2013 16:34:14 +0200 From: keramida@ceid.upatras.gr (Giorgos Keramidas) To: Dimitry Andric <dim@FreeBSD.org> Cc: svn-src-head@FreeBSD.org, Gregory Shapiro <gshapiro@FreeBSD.org>, src-committers@FreeBSD.org, svn-src-all@FreeBSD.org, Bruce Evans <brde@optusnet.com.au> Subject: Re: svn commit: r246880 - in head: lib/libsm libexec/mail.local libexec/smrsh share/mk usr.bin/vacation usr.sbin/sendmail Message-ID: <87r4iaa6jd.fsf@saturn.laptop> In-Reply-To: <516D55C4.1050102@FreeBSD.org> (Dimitry Andric's message of "Tue, 16 Apr 2013 15:44:36 %2B0200") References: <201302162017.r1GKHVdY022667@svn.freebsd.org> <87a9ozayzk.fsf@saturn.laptop> <516D13C5.70900@FreeBSD.org> <20130416205349.W1783@besplex.bde.org> <516D55C4.1050102@FreeBSD.org>
next in thread | previous in thread | raw e-mail | index | archive | help
On Tue, 16 Apr 2013 15:44:36 +0200, Dimitry Andric <dim@FreeBSD.org> wrote: > On 2013-04-16 13:28, Bruce Evans wrote: >> Extending the example a little gives the answer to my question: >> >> @ #include <stdbool.h> >> @ >> @ typedef void vb(bool first); >> @ >> @ vb foo; >> @ void bar(vb *p); >> @ >> @ void >> @ foo(first) >> @ bool first; >> @ { >> @ bar(foo); >> @ } >> >> @ z.c:10:7: warning: promoted type 'int' of K&R function parameter is >> not compatible with the parameter type 'bool' declared in a previous >> prototype [-Wknr-promoted-parameter] >> @ bool first; >> @ ^ >> @ z.c:5:4: note: previous declaration is here >> @ vb foo; >> @ ^ >> @ z.c:12:6: warning: incompatible pointer types passing 'void ()' to parameter of type 'vb *' (aka 'void (*)(bool)') [-Wincompatible-pointer-types] >> @ bar(foo); >> @ ^~~ >> @ z.c:6:14: note: passing argument to parameter 'p' here >> @ void bar(vb *p); >> @ ^ >> @ 2 warnings generated. >> >> Apparently clang ignores the mismatched prototype after printing a warning >> about it, and also throws away the type info that it learns by compiling >> the K&R function, so it is left with only 'void ()' for the type. > > Yes, this is basically what happens. The actual definition of the > function overrides the prototype, if it comes before the invocation. > > For example, in the original problem case, the warning could also be > worked around by moving the getsasldata() definition to below > attemptauth(), where it is invoked. This still counts as cheating, > though. :-) And that's precisely why other functions, like esmtp_check() do not have the same problem, even though they have exactly the same signature and they are used in the same way!
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?87r4iaa6jd.fsf>