retval = false && someFunction(); // Does someFunction() get called?
<p>I'm currently working with the Diab 4.4 C++ compiler. It's a total POS, non ANSI-compliant, and I've found problems with it in the past.</p>

<p>I'm wondering if the following problem is an issue with the compiler, or a shortcoming in my knowledge of C++</p>

<p>I realize that the form of x = x &amp;&amp; y; will short-circuit the y part if x is false. What the compiler is doing is short-circuiting in the case of x = x &amp;&amp; y(); where y() is a non-const function.</p>

<pre><code>class A
{
int _a;
A(int a) { _a = a; }
bool someFunction() { _a = 0; return true; } 
};

main(...)
{
A obj = A(1);
bool retval = false;

retval = retval &amp;&amp; A.someFunction();

/* What is the value of A._a here? */
}
</code></pre>

<p>What seems wrong to me is the fact that the compiler is doing this short-circuiting even though someFunction() is not a const function. If it's not const, is the compiler overstepping its bounds by skipping A.someFunction() when retval is false?</p>

<p>Also, I realize this issue can be avoided by writing retval = A.someFunction() &amp;&amp; retval; but I'd really like to know why this is happening.</p>
