[cfe-dev] minimal repro for incorrect compilation with -Os on clang++ version 3.2-1

Frederic de Mesmay drefleladi at gmail.com
Fri Mar 22 14:01:18 PDT 2013


Dear clang devs,

I hope this is the right place to post a bug report.
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).

Thank you for making such a great product.

Yours Sincerely,
Gurg Hackpof

---------------------------

fred at virtualbuntu:~$ clang++ -std=c++11 -O min-example.cpp -o working
fred at virtualbuntu:~$ ./working
fred at virtualbuntu:~$ clang++ -std=c++11 -Os min-example.cpp -o buggy
fred at virtualbuntu:~$ ./buggy
terminate called after throwing an instance of 'int'
Aborted (core dumped)


fred at virtualbuntu:~$ clang++ -v
Ubuntu clang version 3.2-1~exp5ubuntu2 (tags/RELEASE_32/final) (based on
LLVM 3.2)
Target: x86_64-pc-linux-gnu
Thread model: posix


fred at virtualbuntu:~$ cat min-example.cpp
#include <boost/optional.hpp>

struct Parent {
        int one;
        Parent() : one(1){}
        void throwParent(const boost::optional<int>& arg) {
                if (one == 1) {
                        throw 666;
                } else {
                        notUsed(arg);
                }
        }
        virtual void notUsed( const boost::optional<int>& arg) = 0;
};

struct Child : public Parent {
        virtual void notUsed( const boost::optional<int>& arg) override {
        }
        void throwChild() {
                throwParent(boost::none);
        }
};

int main(){
        try {
                Child().throwChild();
        } catch( int ) {
                return 0;
        }
}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20130322/b5e14690/attachment.html>


More information about the cfe-dev mailing list