Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
| From | Keith Thompson <kst-u@mib.org> |
|---|---|
| Newsgroups | comp.lang.c |
| Subject | Re: Type interchange |
| Date | 2011-12-01 14:31 -0800 |
| Organization | None to speak of |
| Message-ID | <ln62hzq5zh.fsf@nuthaus.mib.org> (permalink) |
| References | (3 earlier) <4ED6C5F0.1080608@verizon.net> <0.041cc3761d33f47105cd.20111201030905GMT.87d3c9ouni.fsf@bsb.me.uk> <jb7r0i$9ku$3@dont-email.me> <0.62ba56f0dbe6531a64e1.20111201155527GMT.871usop9qo.fsf@bsb.me.uk> <4ED7AB31.1010500@verizon.net> |
James Kuyper <jameskuyper@verizon.net> writes:
> On 12/01/2011 10:55 AM, Ben Bacarisse wrote:
>> James Kuyper <jameskuyper@verizon.net> writes:
>>
>>> On 11/30/2011 10:09 PM, Ben Bacarisse wrote:
>> <snip>
>>>> Types are compatible or not as defined by the standard,
>>>
>>> Yes, and the standard leaves the compatibility of types A and B
>>> unspecified for a very large number of possible pairs of A and B,
>>> including A='int' and B='long'.
>>
>> I don't think it does. For your interpretation to be correct the
>> standard must fail to say if int and long are the same type. The rule
>> is simple:
>>
>> "Two types have compatible type if their types are the
>> same. Additional rules for determining whether two types are
>> compatible..."
>
> I never claimed that 'int' and 'long' could be compatible by reason of
> being the same type. When I said that they could be compatible for a
> particular implementation, I meant that this possibility exists despite
> their being different types.
>
> Some of the other rules referred to by 6.2.7p1 are worded in such a way
> that any pair of types that they apply to which aren't identified as
> compatible by that rule, must be incompatible. For instance, 6.7.3p9
> says "For two qualified types to be compatible, both shall ..."; which
> implies quite clearly that any pair of qualified types that don't match
> the description following the "shall" are not compatible. However,
> neither 'int' nor 'long' is a qualified type, so that doesn't apply.
> Neither do any of the other rules referenced by 6.2.7p1.
>
> 6.2.7p1 itself contains no such wording. It could have been written as:
> For two types to be compatible, they must either be the same type, or
> covered by one of the additional rules in ...". It wasn't written that way.
We know the standard is not 100% internally consistent.
I think that 6.2.7p1 should have been written as you suggest.
I think that your suggested wording is consistent with the intent.
The consequences of another interpretation are, IMHO, quite painful:
For an implementation where int and long have the same
representation, they *may or may not* be compatible, depending on
the implementation. There is no requirement for this choice to
be documented. Which means that this:
int *ip = 0;
long *lp = ip;
either does or does not violate a constraint, depending on an
undocumented characteristic of the implementation.
Furthermore, under your interpretation, I see nothing saying that
int and long must have the same representation to be compatible.
An implementation could have 32-bit int and 64-bit long, but if
it decides that int and long are compatible types, then the above
declarations may be accepted without so much as a warning.
My position: The definition of "compatible type" is intended to
be exhaustive, even though the standard doesn't say so explicitly.
int and long are incompatible for every implementation (and therefore
int* and long* are incompatible for every implementation).
--
Keith Thompson (The_Other_Keith) kst-u@mib.org <http://www.ghoti.net/~kst>
Will write code for food.
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
Back to comp.lang.c | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Type interchange Edward Rutherford <edward.p.rutherford79@REMOVETHIS.gmail.com> - 2011-11-30 21:53 +0000
Re: Type interchange James Kuyper <jameskuyper@verizon.net> - 2011-11-30 17:29 -0500
Re: Type interchange Keith Thompson <kst-u@mib.org> - 2011-11-30 15:22 -0800
Re: Type interchange James Kuyper <jameskuyper@verizon.net> - 2011-11-30 19:10 -0500
Re: Type interchange Ben Bacarisse <ben.usenet@bsb.me.uk> - 2011-12-01 03:09 +0000
Re: Type interchange James Kuyper <jameskuyper@verizon.net> - 2011-12-01 07:13 -0500
Re: Type interchange Ben Bacarisse <ben.usenet@bsb.me.uk> - 2011-12-01 15:55 +0000
Re: Type interchange James Kuyper <jameskuyper@verizon.net> - 2011-12-01 11:28 -0500
Re: Type interchange Ben Bacarisse <ben.usenet@bsb.me.uk> - 2011-12-01 16:45 +0000
Re: Type interchange James Kuyper <jameskuyper@verizon.net> - 2011-12-01 12:00 -0500
Re: Type interchange Keith Thompson <kst-u@mib.org> - 2011-12-01 14:31 -0800
Re: Type interchange James Kuyper <jameskuyper@verizon.net> - 2011-12-01 20:18 -0500
Re: Type interchange Keith Thompson <kst-u@mib.org> - 2011-12-01 17:35 -0800
Re: Type interchange James Kuyper <jameskuyper@verizon.net> - 2011-12-02 12:03 -0500
Re: Type interchange Keith Thompson <kst-u@mib.org> - 2011-12-02 13:49 -0800
Re: Type interchange James Kuyper <jameskuyper@verizon.net> - 2011-12-02 22:12 -0500
Re: Type interchange Keith Thompson <kst-u@mib.org> - 2011-12-03 02:01 -0800
Re: Type interchange Tim Rentsch <txr@alumni.caltech.edu> - 2012-01-25 12:47 -0800
Re: Type interchange pete <pfiland@mindspring.com> - 2011-12-01 11:10 -0500
Re: Type interchange James Kuyper <jameskuyper@verizon.net> - 2011-12-01 11:34 -0500
Re: Type interchange Kaz Kylheku <kaz@kylheku.com> - 2011-12-01 17:48 +0000
Re: Type interchange Keith Thompson <kst-u@mib.org> - 2011-12-01 14:17 -0800
Re: Type interchange pete <pfiland@mindspring.com> - 2011-12-01 17:43 -0500
Re: Type interchange Keith Thompson <kst-u@mib.org> - 2011-12-01 15:00 -0800
Re: Type interchange pete <pfiland@mindspring.com> - 2011-12-01 19:29 -0500
Re: Type interchange Keith Thompson <kst-u@mib.org> - 2011-12-01 16:59 -0800
Re: Type interchange pete <pfiland@mindspring.com> - 2011-12-02 08:35 -0500
Re: Type interchange James Kuyper <jameskuyper@verizon.net> - 2011-12-02 08:46 -0500
Re: Type interchange Keith Thompson <kst-u@mib.org> - 2011-12-02 13:32 -0800
Re: Type interchange Keith Thompson <kst-u@mib.org> - 2011-12-02 13:30 -0800
Re: Type interchange pete <pfiland@mindspring.com> - 2011-12-02 18:45 -0500
Re: Type interchange Keith Thompson <kst-u@mib.org> - 2011-11-30 19:17 -0800
Re: Type interchange James Kuyper <jameskuyper@verizon.net> - 2011-12-01 06:50 -0500
Re: Type interchange Keith Thompson <kst-u@mib.org> - 2011-12-01 07:15 -0800
Re: Type interchange James Kuyper <jameskuyper@verizon.net> - 2011-12-01 10:36 -0500
Re: Type interchange pete <pfiland@mindspring.com> - 2011-12-01 11:04 -0500
Re: Type interchange James Kuyper <jameskuyper@verizon.net> - 2011-12-01 11:37 -0500
Re: Type interchange Tim Rentsch <txr@alumni.caltech.edu> - 2012-01-25 13:02 -0800
Re: Type interchange Tim Rentsch <txr@alumni.caltech.edu> - 2012-01-25 13:01 -0800
Re: Type interchange Quentin Pope <qp19433@hotmail.NOSPAM.com> - 2011-12-02 22:15 +0000
Re: Type interchange James Kuyper <jameskuyper@verizon.net> - 2011-12-03 11:39 -0500
csiph-web