title: Conditional breakpoint: This expression has side effects and will not be evaluated
body: <p>I have a non-static const method called <code>size_t A::m() const</code>, which I want to use to trigger a breakpoint if it returns a value greater than 1. Here is <code>class A</code> and instance <code>a</code>:</p>
  
  <pre><code>class A
  {
  public:
      std::vector&lt;double&gt; myvec;
      size_t m() const
      {
        return myvec.size();
      }
  } a;
  </code></pre>
  
  <p>So I add a breakpoint in Visual Studio 2013 with this condition</p>
  
  <pre><code>a.m() &gt; 1 // a is an instance of class A
  </code></pre>
  
  <p>However, when I try to compile this I get the following message from the IDE:</p>
  
  <blockquote>
    <p>The following breakpoint cannot be set:</p>
    
    <p>At myFile.cpp, line xxx, when 'a.m() > 1' is true</p>
    
    <p>This expression has side effects and will not be evaluated.</p>
  </blockquote>
  
  <p>Note that <code>A::m()</code> does not modify anything, it only calls the <code>.size()</code> method of a vector and returns that value, so the assertion that the expression has side effects is simply false. In fact, <em>replacing</em> the breakpoint condition with <code>a.myvec.size() &gt; 1</code> (ie. the content of the method itself) has the same effect!</p>
  
  <p>Regarding what can be used as a conditional in a breakpoint, <a href="http://msdn.microsoft.com/en-us/library/vstudio/5557y8b4.aspx#BKMK_Create_breakpoints_that_break_when_you_want">Microsoft says that</a>;</p>
  
  <blockquote>
    <p>The condition can be any valid expression that is recognized by the
    debugger.</p>
  </blockquote>
  
  <p>So I went and had a look at <a href="http://msdn.microsoft.com/en-us/library/vstudio/za56x861.aspx">Expressions in the Debugger</a>, and <a href="http://msdn.microsoft.com/en-us/library/vstudio/a7a250bs.aspx">found this</a>:</p>
  
  <blockquote>
    <p>One common cause of side effects is evaluating a function call in a
    debugger window. Such evaluations are usually noticeable. A more
    subtle cause of side effects is the evaluation of properties and other
    implicit function calls in managed code.</p>
    
    <p>The debugger cannot tell whether a property evaluation or implicit
    function call has side effects. Therefore, by default, the debugger
    does not evaluate implicit function calls automatically. Property
    evaluation is allowed by default, but can be turned off in the Options
    dialog box. When a function call or property has not been evaluated, a
    refresh icon appears. You can manually evaluate the expression by
    clicking the refresh icon. For details, see How to: Refresh Watch
    Values.</p>
    
    <p>When evaluation of properties or implicit function calls is turned
    off, you can force evaluation by using the ac format modifier (for C#
    only). See <a href="http://msdn.microsoft.com/en-us/library/vstudio/e514eeby.aspx">Format Specifiers in C#.</a></p>
  </blockquote>
  
  <p>If someone could translate the above paragraph to English that would be great. Can I put functions in these debugger conditionals or not?</p>