clang++ -Os compiles incorrectly

Bug #1159667 reported by Gurg Hackpof
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
LLVM
Fix Released
Medium
clang (Ubuntu)
New
Undecided
Unassigned

Bug Description

Current raring (as of 24/03/2013) suffers of this clang++ bug (http://llvm.org/bugs/show_bug.cgi?id=15574) which has been fixed upstream

Tags: bot-comment
Revision history for this message
In , Drefleladi-8 (drefleladi-8) wrote :

Created attachment 10230
output of clang -E min-example.cpp

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).
Boost is coming from libboost-dev 1.49.0.1 (also from the latest ubuntu beta)

Also, the output of "clang -E min-example.cpp" is attached to the bug report.

Thank you for making such a great product.

Yours Sincerely,
Gurg Hackpof

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

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

fred@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@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;
        }
}

Revision history for this message
In , Richard-llvm (richard-llvm) wrote :

I can reproduce this at r174769 but not at r177768; I'm assuming this has already been fixed. Please reopen if you can reproduce this with a trunk build.

Revision history for this message
Ubuntu Foundations Team Bug Bot (crichton) wrote :

Thank you for taking the time to report this bug and helping to make Ubuntu better. It seems that your bug report is not filed about a specific source package though, rather it is just filed against Ubuntu in general. It is important that bug reports be filed about source packages so that people interested in the package can find the bugs about it. You can find some hints about determining what package your bug might be about at https://wiki.ubuntu.com/Bugs/FindRightPackage. You might also ask for help in the #ubuntu-bugs irc channel on Freenode.

To change the source package that this bug is filed about visit https://bugs.launchpad.net/ubuntu/+bug/1159667/+editstatus and add the package name in the text box next to the word Package.

[This is an automated message. I apologize if it reached you inappropriately; please just reply to this message indicating so.]

tags: added: bot-comment
affects: ubuntu → clang (Ubuntu)
Revision history for this message
Sylvestre Ledru (sylvestre) wrote :

Well, without the commit revision which fixes this issue (and therefor the patch), it will be hard to see this bug fixed for raring.

Revision history for this message
Gurg Hackpof (drefleladi) wrote :

My opinion is that it is quite ominous to leave a bug such as this one in the wild.

ICE-ing is one thing, runtime-crashing is another but plain incorrect branching renders this compiler worse than useless: untrustable and also potentially a security issue.

not sure who I need to petition, but even the bleeding svn head would be better than a snapshot that is proven hazardous!

Revision history for this message
Sylvestre Ledru (sylvestre) wrote :

The SVN has (way) too much differences compared to the 3.2 official release. It is clearly a no-go.

Changed in llvm:
importance: Unknown → Medium
status: Unknown → Fix Released
Revision history for this message
In , Gurg Hackpof (drefleladi) wrote :

Richard: Is it possible to track down what might have been the patch(es) ?

I'd be quite happy to see this fixed in the next ubuntu (https://bugs.launchpad.net/ubuntu/+source/clang/+bug/1159667)

Thanks,

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.