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: Regarding assignment to struct
Date: Mon, 05 May 2025 17:04:06 -0700
Organization: A noiseless patient Spider
Lines: 26
Message-ID: <867c2u4nbd.fsf@linuxsc.com>
References: <86plgo7ahu.fsf@linuxsc.com> <20250505111213.00004b55@yahoo.com> <20250505120145.000014f8@yahoo.com> <87jz6uhkgo.fsf@nosuchdomain.example.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Injection-Date: Tue, 06 May 2025 02:04:06 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="f84420402be78ce51ba0e8f0077f27e2"; logging-data="1634369"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19T/psBMdAUwa8ohUt3obrloaJyOmg1f8o="
User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.4 (gnu/linux)
Cancel-Lock: sha1:dhcfVGOtol2VhyYRS/TdudxuWrU= sha1:l19qENOdhL7yn+dRfwweaNoTARE=
Xref: csiph.com comp.lang.c:393194
Keith Thompson writes:
> Andrey Tarasevich writes:
> [...]
>
>> #include
>>
>> 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.