Path: csiph.com!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!eternal-september.org!.POSTED!not-for-mail
From: Tim Rentsch
Newsgroups: comp.lang.c
Subject: Re: do { quit; } else { }
Date: Tue, 08 Apr 2025 10:32:23 -0700
Organization: A noiseless patient Spider
Lines: 46
Message-ID: <868qoaeezc.fsf@linuxsc.com>
References: <8634enhcui.fsf@linuxsc.com> <86ldsdfocs.fsf@linuxsc.com> <20250406161323.00005809@yahoo.com> <86ecy5fjin.fsf@linuxsc.com> <20250406190321.000001dc@yahoo.com> <86plhodtsw.fsf@linuxsc.com> <20250407210248.00006457@yahoo.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Injection-Date: Tue, 08 Apr 2025 19:32:24 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="3be70bfd357a158f55184c1ca57022b7"; logging-data="2859686"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18hnyxYErvNn+U4ty+uVthlpjYJ5ynHNjE="
User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.4 (gnu/linux)
Cancel-Lock: sha1:Alr1DxLkWzbt1vxfekzuXyJYC7s= sha1:BRoibES3iBBK2Yby+RrL1DCTMVw=
Xref: csiph.com comp.lang.c:392206
bart writes:
> On 08/04/2025 15:50, David Brown wrote:
>
>> On 08/04/2025 13:35, bart wrote:
>>
>>> But this need not be the case. For example this is module A:
>>>
>>> --------------------------
>>> #include
>>>
>>> typedef struct point {float a; float b;} Point;
>>>
>>> float dist(Point);
>>>
>>> int main(void) {
>>> Point p = {3, 4};
>>> printf("%f\n", dist(p));
>>> }
>>> --------------------------
>>>
>>> And this is module B that defines 'dist':
>>>
>>>
>>> --------------------------
>>> #include
>>>
>>> typedef float length;
>>> typedef struct _tag {length x, y;} vector;
>>>
>>> length dist(vector p) {return sqrt(p.x*p.x + p.y*p.y);}
>>> --------------------------
>>>
>>> The types involved are somewhat different, but are compatible
>>> enough for it to work.
>>
>> The two types are entirely compatible.
>
> Are they?
No, they are not. The type names 'Point' and 'vector' name two
distinct types, and those types are not compatible, because
the two struct tags are different.
Because the two types are not compatible, even just calling the
function dist() is undefined behavior.