Sujet : Re: A Famous Security Bug
De : bc (at) *nospam* freeuk.com (bart)
Groupes : comp.lang.cDate : 22. Mar 2024, 22:41:43
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <utktul$35ng8$1@dont-email.me>
References : 1 2 3 4
User-Agent : Mozilla Thunderbird
On 22/03/2024 17:14, James Kuyper wrote:
On 3/21/24 14:13, Anton Shepelev wrote:
...
I think this behavior (of a C compiler) rather stupid. In a
low-level imperative language, the compiled program shall
do whatever the programmer commands it to do.
C is NOT that low a level of language. The standard explicitly allows
implementations to use any method they find convenient to produce
observable behavior which is consistent with the requirements of the
standard. Despite describing how that behavior might be produced by the
abstract machine, it explicitly allows an implementation to achieve that
behavior by other means.
If you want to tell a system not only what a program must do, but also
how it must do it, you need to use a lower-level language than C.
Which one?
I don't think anyone seriously wants to switch to assembly for the sort of tasks they want to use C for.
I agree with AS that a program should do what it's told by the programmer and the compiler should not get too smart.
When /I/ implement such a language, then that's pretty much what happens.
However, people also expect a reasonable amount of optimisation, which can involve take some short-cuts or not doing precisely what the programmer wrote, in the detail.
So the line isn't clearly defined as to what is or isn't acceptable.
But in this example where somebody has clearly requested an object to be zeroed, ignoring that instruction has crossed the line to unacceptable IMO.