Topic: Encountering else without having executed an if, was: 'if


Author: Robert Mabee <rmabee@comcast.net>
Date: Sun, 15 Apr 2007 10:48:35 CST
Raw View
James Kanze wrote:
> The problem is
> trying to figure out what should happen, according to the
> standard, if you enter the if statement by jumping over the
> evaluation of the condition.  The words I quoted could be taken
> to suggest that on encountering the else, the condition must be
> evaluated in order to determine whether the else part is to be
> executed or not.

It should be sufficient to notice that the condition expression can
not in general be evaluated again, both because it may not be idempotent
and because (in the case that the if-true statement was executed) the
values referenced in the condition may have changed.  Therefore the
only possible interpretation is that the condition result is effectively
preserved.

Is the issue whether a compiler could use an actual variable for the
condition result, and neglect to set the variable on jumping into the
if, and still claim conformance because this is undefined behavior?

---
[ 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://www.comeaucomputing.com/csc/faq.html                      ]