Path: csiph.com!eternal-september.org!feeder.eternal-september.org!nntp.eternal-september.org!.POSTED!not-for-mail From: Tim Rentsch Newsgroups: comp.lang.c Subject: Re: Regarding assignment to struct Date: Sun, 01 Mar 2026 18:54:36 -0800 Organization: A noiseless patient Spider Lines: 42 Message-ID: <86ldgbeyab.fsf@linuxsc.com> References: <86plgo7ahu.fsf@linuxsc.com> <20250505111213.00004b55@yahoo.com> <20250505120145.000014f8@yahoo.com> <87jz6uhkgo.fsf@nosuchdomain.example.com> <867c2u4nbd.fsf@linuxsc.com> <87r012ftl1.fsf@nosuchdomain.example.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Injection-Date: Mon, 02 Mar 2026 02:54:39 +0000 (UTC) Injection-Info: dont-email.me; posting-host="879346d16fc7c1cd3f18baf5c462c148"; logging-data="805250"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/546fOEwebpyNvbnVHEmubOtL0bIl0a6I=" User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.4 (gnu/linux) Cancel-Lock: sha1:ctJac+M/gE8f/91A/LPk8axwKeM= sha1:v773THhC7mzqcGG5NHzJOKZ9+3g= Xref: csiph.com comp.lang.c:396714 Keith Thompson writes: > Tim Rentsch writes: > >> 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. > > 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. I wasn't thinking about your reasoning or what flaw there may have been in it. My intention was to suggest a course of action that would be helpful rather than to point out any sort of mistake. But since you ask, I think the mistake you made was jumping to a conclusion without looking carefully enough at the problem.