Path: csiph.com!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!eternal-september.org!.POSTED!not-for-mail From: Keith Thompson 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: <86plgo7ahu.fsf@linuxsc.com> <20250505111213.00004b55@yahoo.com> <20250505120145.000014f8@yahoo.com> <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= Xref: csiph.com comp.lang.c:393195 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. -- Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com void Void(void) { Void(); } /* The recursive call of the void */