Re: Same code and different result, Why?
- From: "Bo Persson" <bop@xxxxxx>
- Date: Sat, 8 Nov 2008 11:23:29 +0100
Tommy wrote:
Alex Blekhman wrote:
and best from what I tell, its a MS Compiler issue only -
excused with the documented sequence point idea.
No, it is undefined for all other compilers, as well. The notion
of sequence point is common for all C/C++ compilers. However, the
exact place where sequence point occurs may vary from vendor to
vendor.
I think that B. Stroustrup answerd to you claim better than I
could:
"Why are some things left undefined in C++?"
http://www.research.att.com/~bs/bs_faq2.html#undefined
Alex, you missed the point. I'll try it this way.
In every technology, protocol, what have you, when they is a lack of
consensus, in principle, you use the best practice. This is part
for the course for the technology you are using right now, the
compiler, including the news groups protocol NNTP (RFC 977) you are
using, as well as, and especially in Email (RFC 5321) technology.
In all cases, it is not that behavior is not defined, it is
indeterministic, there could be many behaviors but generally well
defined set of behavior. So in principle, there is lack of
consensus for what is the correct behavior - which one is deemed
"more" correct.
This isn't a software only problem. What is "correct" behavior is
sometimes decided by the underlying hardware, and they are different.
On some hardware, the code sequence
y = *x++;
might be a single machine instruction, if x is stored in a register.
Now, the compiler writers for such a machine would be really upset if
they could not use that instruction, just because you sometimes want
to write
x = *x++;
instead. Making this well defined, might make everything else run
slower, on some hardware. Good or bad?
One concrete example of this is Java requireing IEEE floating point.
Regular and well defined. However, IBM mainframes do not have that, so
they require a $100k hardware extension to run Java properly.
http://www-03.ibm.com/systems/z/advantages/zaap/index.html
C++ doesn't specify its floating point format, and therefore works
without any extra hardware.
Bo Persson
.
- Follow-Ups:
- Re: Same code and different result, Why?
- From: Igor Tandetnik
- Re: Same code and different result, Why?
- References:
- Same code and different result, Why?
- From: Lorry Astra
- Re: Same code and different result, Why?
- From: Alex Blekhman
- Re: Same code and different result, Why?
- From: Tommy
- Re: Same code and different result, Why?
- From: Ulrich Eckhardt
- Re: Same code and different result, Why?
- From: Tommy
- Re: Same code and different result, Why?
- From: Alex Blekhman
- Re: Same code and different result, Why?
- From: Tommy
- Same code and different result, Why?
- Prev by Date: Re: Same code and different result, Why?
- Next by Date: Re: How to insert an element in the middle of the list?
- Previous by thread: Re: Same code and different result, Why?
- Next by thread: Re: Same code and different result, Why?
- Index(es):
Relevant Pages
|