Groups | Search | Server Info | Keyboard shortcuts | Login | Register


Groups > comp.lang.c > #393389

Re: do { quit; } else { }

From Keith Thompson <Keith.S.Thompson+u@gmail.com>
Newsgroups comp.lang.c
Subject Re: do { quit; } else { }
Date 2025-05-13 17:51 -0700
Organization None to speak of
Message-ID <87wmakaubu.fsf@nosuchdomain.example.com> (permalink)
References (16 earlier) <861psuziq2.fsf@linuxsc.com> <vvt13g$14otk$1@dont-email.me> <87ecwt37b9.fsf@nosuchdomain.example.com> <vvv43b$1o3o0$1@dont-email.me> <1000ne2$2323t$1@dont-email.me>

Show all headers | View raw


James Kuyper <jameskuyper@alumni.caltech.edu> writes:
> On 5/13/25 05:40, David Brown wrote:
>> On 12/05/2025 22:25, Keith Thompson wrote:
> ...
>>> I think that a lot of C programmers misunderstand what "compatible
>>> types" means. Many seem to think that two types are compatible if
>>> they have the same representation and can be assigned without a cast.
>>
>> Yes. Basically, most C programmers are not particularly aware of the
>> technical definitions of some of the terms in C standards where they
>> differ from common usage. The word "compatible" in English means that
>> the things in question can work together or fit together.
>
> That's pretty much what it means in C. Two C types are compatible in C
> if the C standard *guarantees* that they can work together - that you
> can use the types interchangeably. The tricky part is the definition of
> which pairs of types the C standard makes those guarantees for.
> The key point is that the undefined behavior of code which treats
> incompatible types as if they were compatible could also be that they
> work together, too, depending upon the implementation.

I suggest that the phrase "work together" is too vague.  It's
perfectly reasonable to say that two types that can be assigned to
each other without casts can "work together", and I might even call
them "compatible" if the standard didn't already define the term.

To a first approximation, two types are compatible if they're the
same type.  The standard's section on compatible types points to
additional rules for some cases.  IMHO the English word "compatible"
suggests a much looser relationship, but we're stuck with the
standard's terminology (and I'm not sure what would be better).

-- 
Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com
void Void(void) { Void(); } /* The recursive call of the void */

Back to comp.lang.c | Previous | NextPrevious in thread | Next in thread | Find similar


Thread

Re: do { quit; } else { } Tim Rentsch <tr.17687@z991.linuxsc.com> - 2025-05-11 19:05 -0700
  Re: do { quit; } else { } David Brown <david.brown@hesbynett.no> - 2025-05-12 16:37 +0200
    Re: do { quit; } else { } Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2025-05-12 13:25 -0700
      Re: do { quit; } else { } David Brown <david.brown@hesbynett.no> - 2025-05-13 11:40 +0200
        Re: do { quit; } else { } James Kuyper <jameskuyper@alumni.caltech.edu> - 2025-05-13 20:17 -0400
          Re: do { quit; } else { } Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2025-05-13 17:51 -0700
            Re: do { quit; } else { } James Kuyper <jameskuyper@alumni.caltech.edu> - 2025-05-13 22:23 -0400
              Re: do { quit; } else { } David Brown <david.brown@hesbynett.no> - 2025-05-14 11:07 +0200
                Re: do { quit; } else { } Kaz Kylheku <643-408-1753@kylheku.com> - 2025-05-14 15:03 +0000
                Re: do { quit; } else { } James Kuyper <jameskuyper@alumni.caltech.edu> - 2025-05-14 23:17 -0400
            Re: do { quit; } else { } David Brown <david.brown@hesbynett.no> - 2025-05-14 11:22 +0200
          Re: do { quit; } else { } Tim Rentsch <tr.17687@z991.linuxsc.com> - 2025-05-13 18:15 -0700

csiph-web