Path: csiph.com!eternal-september.org!feeder.eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail From: Keith Thompson Newsgroups: comp.lang.c Subject: Re: "Conversions" of types Date: Mon, 10 Jun 2019 14:00:02 -0700 Organization: None to speak of Lines: 44 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Injection-Info: reader02.eternal-september.org; posting-host="a48fc62188096381b639076ca22e4dd1"; logging-data="6177"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+ammlH8nT0E8ZR8FvQK3hJ" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux) Cancel-Lock: sha1:fJANxHod8sWWsPQWXoXDDG9KRQw= sha1:EabIZd/C/8zs7Rmoxuo+soOTJXI= Xref: csiph.com comp.lang.c:144719 unidef writes: > Keith Thompson wrote: >> ram@zedat.fu-berlin.de (Stefan Ram) writes: >>> |Any pointer type may be converted to an integer type. >>> N2310, 6.3.2.3p6 >>> >>> If this is true, then may I ask: Which integer type >>> is the result of the conversion of the pointer type >>> »double *« to an integer type? >>> >>> Don't they mean: >>> >>> Any /value of/ an expression of pointer type may be >>> converted to a /value of/ an integer type. >> >> Yes. >> >>> ? Or does it really make sense to say that a /type/ >>> can be converted to another type? >> >> No. The wording in the standard is slightly informal. The intent is >> clear enough that I don't have a problem with it, though I wouldn't >> mind if it were changed to refer to values. >> > > You gotta look into the machines native assembly code to make sense out of > casting. I don’t know assembly that well :( No, you don't have to look at assembly code to make sense out of casting. The semantics of casts, and more generally of type conversions, are defined by the standard (and are left implementation-defined in some cases). For pointer conversions (pointer-to-pointer, pointer-to-integer, or integer-to-pointer), it helps to know how pointers are represented, but knowing about the CPU instructions instructions that act on them is not particularly helpful. On most systems, pointer conversions just copy the bits; the only slightly tricky part is making sure that the source and target have consistent sizes. -- Keith Thompson (The_Other_Keith) kst-u@mib.org Will write code for food. void Void(void) { Void(); } /* The recursive call of the void */