Modify const variable in const member bad pratice or UB?
<p>Is the code below bad practice or undefined behavior? Essentially i am calling a const func to modify a member which is not marked as mutable. Link to <a href="http://ideone.com/ga5hm" rel="nofollow">demo</a></p>

<p>Credits to Mehrdad for inspiring this question (his question <a href="http://stackoverflow.com/questions/11077566/does-this-code-subvert-the-c-type-system">Does this code subvert the C++ type system?</a>) and david for minor demo improvements.</p>

<pre><code>#include &lt;iostream&gt;
using namespace std;

struct BreakConst
{
    int v;
    int *p;
    BreakConst() { v = 0; p = &amp;v; } 
    void break_stuff() const { ++*p; }
};
void f(const BreakConst&amp; bc) {
    bc.break_stuff();
}
</code></pre>

<h3>Original Version that most answers are based on:</h3>

<p>Answered by David Rodríguez, jpalecek, Mehrdad<br>
Yes: This is "Undefined behavior"</p>

<pre><code>int main()
{
    const BreakConst bc;
    cout &lt;&lt; bc.v &lt;&lt; endl;   // 0
    bc.break_stuff();       // O:)
    cout &lt;&lt; bc.v &lt;&lt; endl;   // 1

    return 0;
}
</code></pre>

<h3>New Alternative Question:</h3>

<p>Answered by Mehrdad<br>
No: This is not "Undefined behavior"</p>

<pre><code>int main()
{
    BreakConst bc;
    cout &lt;&lt; bc.v &lt;&lt; endl;   // 0
    f(bc);                  // O:)
    cout &lt;&lt; bc.v &lt;&lt; endl;   // 1

    return 0;
}
</code></pre>

<p>Result:</p>

<pre><code>0
1
</code></pre>
