Topic: Re[2]: 2 questions about Visual C++ vs. standard
Author: Roman Belenov <roman@nstl.nnov.ru>
Date: 1999/12/12 Raw View
Hello Christopher,
CE> I thought the undefined behaviour happens only if the path
CE> is actually taken.
Undefined behaviour term applies to compilation as well as to
execution of the program; refusal to compile is one of the possible
options of handling it.
CE> So for the function f above, the compiler
CE> would have to proof that this function is *ever* called with
CE> a value of x other than 1 or 2, to legally refuse compiling.
Compilation of the function doesn't depend upon the use of it (BTW it
can be called by the code that is not even written by the moment of
the compilation, so such proof is impossible).
CE> Assume f is really intended to take a boolean value,
CE> and only takes int to accomodate an interface that
CE> cannot be changed. Then f would never be called with
CE> anything other than 0 and 1, and the behaviour would
CE> be well defined.
The compiler can't deduce this from the function definition.
Best regards,
Roman mailto:roman@nstl.nnov.ru
Sent via Deja.com http://www.deja.com/
Before you buy.
---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://reality.sgi.com/austern_mti/std-c++/faq.html ]