| Deutsch English Français Italiano |
|
<87r012ftl1.fsf@nosuchdomain.example.com> View for Bookmarking (what is this?) Look up another Usenet article |
Path: ...!weretis.net!feeder9.news.weretis.net!news.quux.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!eternal-september.org!.POSTED!not-for-mail
From: Keith Thompson <Keith.S.Thompson+u@gmail.com>
Newsgroups: comp.lang.c
Subject: Re: Regarding assignment to struct
Date: Mon, 05 May 2025 17:53:14 -0700
Organization: None to speak of
Lines: 36
Message-ID: <87r012ftl1.fsf@nosuchdomain.example.com>
References: <vv338b$16oam$1@dont-email.me> <vv4j9p$33vhj$1@dont-email.me>
<86plgo7ahu.fsf@linuxsc.com> <vv9hu7$3nomg$1@dont-email.me>
<20250505111213.00004b55@yahoo.com> <vv9stv$2i8j$1@dont-email.me>
<20250505120145.000014f8@yahoo.com> <vvame5$ppqp$1@dont-email.me>
<87jz6uhkgo.fsf@nosuchdomain.example.com> <867c2u4nbd.fsf@linuxsc.com>
MIME-Version: 1.0
Content-Type: text/plain
Injection-Date: Tue, 06 May 2025 02:53:15 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="200f1b2c855e9fa31fd1080bfdd034d6";
logging-data="1796087"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18d5hM9AhKcivzOZboixk9m"
User-Agent: Gnus/5.13 (Gnus v5.13)
Cancel-Lock: sha1:vA80EyOb8oITWXk1iq2IcieQRtg=
sha1:9EMoGuRJe1ECuhWTG0lWHN9P04g=
Bytes: 2223
Tim Rentsch <tr.17687@z991.linuxsc.com> writes:
> Keith Thompson <Keith.S.Thompson+u@gmail.com> writes:
>> Andrey Tarasevich <noone@noone.net> writes:
>> [...]
>>
>>> #include <stdio.h>
>>>
>>> struct S { int a[10]; };
>>>
>>> int main()
>>> {
>>> struct S a, b = { 0 };
>>> int *pa, *pb, *pc;
>>>
>>> pa = &a.a[5],
>>> pb = &b.a[5],
>>> pc = &(a = b).a[5],
>>> printf("%p %p %p\n", (void *) pa, (void *) pb, (void *) pc);
>>> }
>>>
>>> This version has no UB.
>>
>> I believe it does. [...]
>
> If you look again carefully, I expect you will reach a
> different conclusion.
Please explain. Or don't.
I explained, in text that you snipped, why I think it has UB.
If there's a flaw in my reasoning, I invite you to point it out
without being mysterious.
--
Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com
void Void(void) { Void(); } /* The recursive call of the void */