<html>
    <head>
      <base href="http://llvm.org/bugs/" />
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW --- - executable behaves differently with -O0 and -O1 (and higher)"
   href="http://llvm.org/bugs/show_bug.cgi?id=17407">17407</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>executable behaves differently with -O0 and -O1 (and higher)
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>clang
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>3.1
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>other
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>normal
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>C++11
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedclangbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>artasano@sbcglobal.net
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>dgregor@apple.com, llvmbugs@cs.uiuc.edu
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Created <span class=""><a href="attachment.cgi?id=11300" name="attach_11300" title="the source code to reproduce the issue.">attachment 11300</a> <a href="attachment.cgi?id=11300&action=edit" title="the source code to reproduce the issue.">[details]</a></span>
the source code to reproduce the issue.

With the attached source, the generated executable behaves correctly with -O0
switch, but behaves incorrectly with -O1 or higher.

If it worked correctly, you see 'GOOD - thrown Actual value [print()] did not
match [zzz]'
If not, you see 'BAD - did not throw'

I tried to simplify the code for ease of investigation, but this is what as far
as I could go.

There are many trials in the source code.
If I change just one of '// reprodices' sections with '// works' alternative,
it works.

I think the key is at line 80 'catch (const Exception&)'.
If I replace it with 'catch (Exception)', it works.

$ clang++ --version
clang version 3.1 (branches/release_31)
Target: i386-pc-cygwin
Thread model: posix</pre>
        </div>
      </p>
      <hr>
      <span>You are receiving this mail because:</span>
      
      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>