This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug lto/42401] New: wrong-code with -flto


> cat main.cc
struct Foo { static void f(); };
int main() { Foo::f(); }


> cat Foo.cc
#include <string>
#include <map>

struct Foo { static void f(); };

void Foo::f()
{
        typedef std::map<int, std::string> Map;
        static Map m;

        Map::const_iterator it = m.find(0);
        if (it != m.end()) {
                std::string s = it->second;
        }
}


> g++ -flto -O3 -c Foo.cc
> g++ -flto -O3 -c main.cc
> g++ -flto -O3 main.o Foo.o
> ./a.out
Segmentation fault (core dumped)


This program works as expected when compiled without -flto. Though when using
-flto it crashes. I'm using SVN revision trunk@155309 on linux x86_64.

I didn't have time yet to reduce this testcase further (expand an reduce the
#includes). I'll try to do that next week.

If you change -O3 into -O0 in the compilation commands but not in the link
command, this test triggers a ICE. But I'll file a different bug for this.


-- 
           Summary: wrong-code with -flto
           Product: gcc
           Version: 4.5.0
            Status: UNCONFIRMED
          Severity: major
          Priority: P3
         Component: lto
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: wouter dot vermaelen at scarlet dot be


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42401


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]