Path: csiph.com!eternal-september.org!feeder.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: Keith Thompson Newsgroups: comp.lang.c Subject: Re: Null pointer constant Date: Mon, 19 Jun 2017 15:16:01 -0700 Organization: None to speak of Lines: 23 Message-ID: References: <9zM1B.193976$KK7.183000@fx12.am4> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Injection-Info: mx02.eternal-september.org; posting-host="6d63db2e8ea996f9a358079ee566ecd1"; logging-data="11779"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18crYfIfaBOHSuXrh6DNCOQ" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux) Cancel-Lock: sha1:JCBOBhejzyqCsTlDr4Ky2HeP9Lg= sha1:B/ehbpMVc1INtCGQdwu23W+N9iM= Xref: csiph.com comp.lang.c:112644 Ike Naar writes: > On 2017-06-19, Keith Thompson wrote: [...] >> If you need to pass a null pointer as a variadic argument, always cast >> it to the appropriate printer type. > > Of course. > > The danger is that, on many platforms, (void*) has the same representation > as any other pointer type, an one is easily lured into the trap of forgetting > the cast. And on many platforms (though not as many), int, void*, and other pointer types all have the same representation, or at least are passed the same way as arguments. Passing a bare 0 as variadic pointer argument is likely to "work" (meaning that the error isn't caught until the code is run on a platform where it fails). -- Keith Thompson (The_Other_Keith) kst-u@mib.org Working, but not speaking, for JetHead Development, Inc. "We must do something. This is something. Therefore, we must do this." -- Antony Jay and Jonathan Lynn, "Yes Minister"