Liste des Groupes | Revenir à c arch |
Tim Rentsch <tr.17687@z991.linuxsc.com> schrieb:
My suggestion is not to implement a language extension, but to
implement a compiler conforming to C as it is now,
Sure, that was also what I was suggesting - define things that
are currently undefined behavior.
with
additional guarantees for what happens in cases that are
undefined behavior.
Guarantees or specifications - no difference there.
Moreover the additional guarantees are
always in effect unless explicitly and specifically requested
otherwise (most likely by means of a #pragma or _Pragma).
Documentation needs to be written for the #pragmas, but no other
documentation is required (it might be nice to describe the
additional guarantees but that is not required by the C
standard).
It' the other way around - you need to describe first what the
actual behavior in absence of any pragmas is, and this needs to be a
firm specification, so the programmer doesn't need to read your mind
(or the source code to the compiler) to find out what you meant.
"But it is clear that..." would not be a specification; what is
clear to you may absolutely not be clear to anybody else.
This is also the only chance you'll have of getting this implemented
in one of the current compilers (and let's face it, if you want
high-quality code, you would need that; both LLVM and GCC
have taken an enormous amount of effort up to now, and duplicating
that is probably not going to happen).
The point is to change the behavior of the compiler but
still conform to the existing ISO C standard.
I understood that - defining things that are currently undefined.
But without a specification, that falls down.
So, let's try something that causes some grief - what should
be the default behavior (in the absence of pragmas) for integer
overflow? More specifically, can the compiler set the condition
to false in
int a;
...
if (a > a + 1) {
}
and how would you specify this in an unabigous manner?
Les messages affichés proviennent d'usenet.