Path: csiph.com!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: rbowman Newsgroups: comp.os.linux.misc,alt.folklore.computers Subject: Re: naughty Python Date: 3 Jan 2026 00:52:51 GMT Lines: 22 Message-ID: References: <79ScnZHy-uXnP8n0nZ2dnZfqnPadnZ2d@giganews.com> <4oycne7Wk4RQ6sj0nZ2dnZfqnPidnZ2d@giganews.com> <10j48fv$2t1h9$12@dont-email.me> <10j5qgf$3etcd$6@dont-email.me> <10j60bb$3hhps$1@dont-email.me> <10j6n9s$3q8au$2@dont-email.me> <10j71fr$3rnk5$1@paganini.bofh.team> <10j88fb$at2l$2@dont-email.me> <20260102084925.000040b5@gmail.com> <10j9dis$mp8i$15@dont-email.me> <10j9f57$ovkv$2@dont-email.me> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Trace: individual.net VyhOoX9C5WcJdYR7t4z5aQhU4XuHtbmm5ReDuZ15TTvdSBa8v+ Cancel-Lock: sha1:7eiEhTYsdJnEimMT/GL5TT/6KmM= sha256:R/wHtBuc+L/uhA8EUk5b0In0qPuGBHArW2F9YRLLnjQ= User-Agent: Pan/0.162 (Pokrosvk) Xref: csiph.com comp.os.linux.misc:80372 alt.folklore.computers:233097 On Fri, 2 Jan 2026 15:00:07 -0700, Peter Flass wrote: > On 1/2/26 14:33, Lawrence D’Oliveiro wrote: >> On Fri, 2 Jan 2026 08:49:25 -0800, John Ames wrote: >> >>> ... it's not guaranteed that the compiler won't take liberties in >>> arranging members of a struct for optimization purposes ... >> >> The C23 spec (section 6.2.5, “Types”) does say the member objects of a >> struct type need to be “sequentially allocated”. The only freedom the >> compiler has (section 6.2.6) is to add “padding bytes”. > > It defeats the purpose of a structure if the compiler is free to > rearrange it. Local variables (PL/I AUTOMATIC) can, in most languages, > be stored however the compiler wants. That can lead to interesting bugs. The root cause is overflowing a local variable, say writing 6 characters to a char[4]. Which adjacent local variable gets whacked depends on the compiler's ordering. Whether it manifests as a bug depends on how the corrupt variable is used in the function and where it is initialized.