"Stephen J. Turnbull" <stephen(a)xemacs.org> writes:
Dmitry> Compiler bugs should be proven. The presence of crash
is
Dmitry> obviously not enough.
Everything should be proven. There should be no crashes. Good luck.
Thanks for the best wishes :-) "Compiler bug" is too strong and relatively
unlikely claim (like "my program crashes because cosmic rays causes
mailfunction in my computer" :-)), so some proof is really needed.
The question is, is it worth proving some particular thing? If you
ask me, the compiler (and library) authors should be more interested
in getting code that works under the broadest possible set of
circumstances rather than defending whatever tricky thing they
currently do, relying on the ability to excuse silly behavior with
"the standard doesn't guarantee sane behavior in this case."
You can propose something else? There is ANSI C standard, that leaves some
things undefined (e.g. for perfomance or portability reasons), so "silly"
is just your emotions. Just an example:
int multiply( int x, int y ){ return x * y; }
/*
*...
*/
int a = 2;
int b = multiply( a++, a);
/* can you predict b value here? */
Would you blame C compilers for that?
Good or bad is the current ANSI C standard, its the only ground we have. If
somebody does not follow the strict standard specs (no matter how logical
or obvious his/her intentions was), it's his/her bug, not the compiler
problem.
While I strongly dislike faking a union with casts, I sympathize
with
Ben having recently had a similar experience with malloc. I don't
think that having a standard is meaningful unless (a) it's obvious by
Patent Office standards or (b) the people who are excusing surprising
behavior with "the standard says it's OK" are willing to explain how to
go about writing compliant code. Neither (a) nor (b) is satisfied in
the "union builds crash when they shouldn't" case.
Which code piece is problematic in the union case? If it's already
discussed in the pass, can you give me the reference? I am asking this over
and over again but does not see any response yet. This talk should be
specific otherwise it's quite useless.
Basically what it comes down to is the compiler writers are saying
"we
don't support union type when you use it to make obscure things clear,
only when you use it to make trivial things verbose." Why bother?
Again, it's just words. Can you show any problematic code?
Ben's reaction, though a little violent, is perfectly plausible:
OK,
we'll deprecate union type since in practice we can't rely on
reasonable behavior.
Please don't misunderstand me, I am not going to teach anybody how to
program. But "fixing" the bugs by avoiding some language constructs
(without any guarantee that the bug won't reveal itself in other place)
does not seem to be very appealing to me...
- Dmitry Bely
P.S. Sorry if my message seems to be offensive for anybody. My intention
was just the technical discussion and nothing else.