<div class="gmail_quote">Dear clang devs,<br><br>I hope this is the right place to post a bug report.<br>You'll find below a simple reproductible example for an incorrect compilation bug that shows up using -Os on clang 3.2-1 (from the latest ubuntu beta).<br>
<br>Thank you for making such a great product.<br><br>Yours Sincerely,<br>Gurg Hackpof<br><br>---------------------------<br><br>fred@virtualbuntu:~$ clang++ -std=c++11 -O min-example.cpp -o working<br>
fred@virtualbuntu:~$ ./working<br>fred@virtualbuntu:~$ clang++ -std=c++11 -Os min-example.cpp -o buggy<br>fred@virtualbuntu:~$ ./buggy<br>terminate called after throwing an instance of 'int'<br>Aborted (core dumped)<br>
<br><br>fred@virtualbuntu:~$ clang++ -v<br>Ubuntu clang version 3.2-1~exp5ubuntu2 (tags/RELEASE_32/final) (based on LLVM 3.2)<br>
Target: x86_64-pc-linux-gnu<br>Thread model: posix<br><br><br>fred@virtualbuntu:~$ cat min-example.cpp<br>#include <boost/optional.hpp><br><br>struct Parent {<br> int one;<br> Parent() : one(1){}<br> void throwParent(const boost::optional<int>& arg) {<br>
if (one == 1) {<br> throw 666;<br> } else {<br> notUsed(arg);<br> }<br> }<br> virtual void notUsed( const boost::optional<int>& arg) = 0;<br>
};<br><br>struct Child : public Parent {<br> virtual void notUsed( const boost::optional<int>& arg) override {<br> }<br> void throwChild() {<br> throwParent(boost::none);<br>
}<br>
};<br><br>int main(){<br> try {<br> Child().throwChild();<br> } catch( int ) {<br> return 0;<br> }<br>}<br><br>
<br>
</div><br>