| Deutsch English Français Italiano |
|
<86ikme2sed.fsf@linuxsc.com> View for Bookmarking (what is this?) Look up another Usenet article |
Path: news.eternal-september.org!eternal-september.org!.POSTED!not-for-mail From: Tim Rentsch <tr.17687@z991.linuxsc.com> Newsgroups: comp.lang.c Subject: Re: Regarding assignment to struct Date: Mon, 05 May 2025 22:57:14 -0700 Organization: A noiseless patient Spider Lines: 43 Message-ID: <86ikme2sed.fsf@linuxsc.com> References: <vv338b$16oam$1@dont-email.me> <vv4j9p$33vhj$1@dont-email.me> <86plgo7ahu.fsf@linuxsc.com> <vv9hu7$3nomg$1@dont-email.me> <87o6w7h2wn.fsf@nosuchdomain.example.com> <20250505120331.000015b2@yahoo.com> <87frhihk8u.fsf@nosuchdomain.example.com> <20250505135415.417@kylheku.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Injection-Date: Tue, 06 May 2025 07:57:15 +0200 (CEST) Injection-Info: dont-email.me; posting-host="f84420402be78ce51ba0e8f0077f27e2"; logging-data="2337910"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/B9UrhCoQrBDAHSzeAfV0QuGAW3tbo4cw=" User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.4 (gnu/linux) Cancel-Lock: sha1:Wa45RHK0WbiAvxzup94PmYztnfY= sha1:nUn+I3SGoNPJ2WMvX8EIUKTTOUE= Kaz Kylheku <643-408-1753@kylheku.com> writes: > On 2025-05-05, Keith Thompson <Keith.S.Thompson+u@gmail.com> wrote: > >> Michael S <already5chosen@yahoo.com> writes: >> >>> On Mon, 05 May 2025 01:34:16 -0700 >>> Keith Thompson <Keith.S.Thompson+u@gmail.com> wrote: >>> >>>> And more obviously, "%p" requires an argument of type void*, not >>>> int*. >>> >>> That part of otherwise very good comment is unreasonably pedantic. >> >> I disagree. I suggest it's a bad habit to use "%p" without >> ensuring, by a cast if necessary, that the argument is of type >> void*. >> >> In most implementations, it's likely that all pointers have the >> same size and representation and are passed as arguments in the >> same way, but getting the types right means one less thing to worry >> about. > > If the codebade assumes all data pointers are the same size, bit > pattern and are treated the same in the calling conventions / ABI, > then it is probably moot. > > That code is doomed on a platform where the assumption doesn't > hold, and the printf statemnts are probably not independently > reusable. > > (I mostly put in these casts just to communicate to others that > an ISO C language lawyer works here, if you happen to need one.) > > Also, it owuld be amazingly stupid of any such platform not just > make those printfs work: to promote variadic arguments of > pointer-to-object type to a common representation which is the > same as void *, combined with a matching behavior in the va_arg > macro for extracting the value back into any pointer-to-object > type. This statement strikes me as would an utterance coming from a resident of Fantasyland.