Sujet : Re: C23 thoughts and opinions
De : cr88192 (at) *nospam* gmail.com (BGB)
Groupes : comp.lang.cDate : 16. Jun 2024, 02:42:47
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <v4lfuq$3rh94$1@dont-email.me>
References : 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
User-Agent : Mozilla Thunderbird
On 6/15/2024 5:42 PM, Lawrence D'Oliveiro wrote:
On Fri, 14 Jun 2024 03:13:32 -0500, BGB wrote:
On 6/14/2024 1:53 AM, Bonita Montero wrote:
>
Am 13.06.2024 um 21:07 schrieb BGB:
>
One possible justification (albeit a weak one) is that if one
recompiles the program with optimizations turned on, in many cases
this may subtly change the behavior of the program (particularly in
relation to things like the contents of uninitialized variables and
dangling pointers, etc...). ...
>
If you rely on that you're misusing the language anyway.
>
It is a poor practice, but seemingly does occur in the wild (intentional
or not).
It seems to me that kind of thing does tend to get flushed out of open-
source code. Because such code is often compiled with different compilers,
on different architectures, using different tool chains etc. And
assumptions like these tend not to survive such treatment.
Yeah, true enough.
Given that these are the sort of things that tend to break whenever the compiler/architecture/optimization settings/etc is changed, then it makes sense that they will get weeded out.
As noted, a lot of the sorts of bugs I had found in this category, was when trying to port various MS-DOS era code to my project.
Though, not too long ago, ran into a similar sort of bug, where the code had "just so happened" to be working because a stack-based array happened to be in the same spot between two functions and just so happened (in the latter call) to contain the data needed from the former function (in this case, perturbing this coincidence would cause the PE/COFF loader to fail to locate binaries; trying to access "some random garbage" rather than the path to the EXE).
I fairly promptly fixed this bug once discovered, and am then just left to wonder how exactly it managed to work in the first place (or didn't break already).
Though, I suspect it may had actually have broken in the past (when poking around at the code generation in BGBCC), but at the time I had thought it was due to "some unknown compiler bug" (and didn't look around enough to realize that it was instead an "uninitialized array contents" bug in the code being compiled).
...