Undefined reference when compiling in O2 (Clang 3.4)

Hi,

I’ve a strange problems with Clang 3.4. I’m on Gentoo and I’m using the official Gentoo version 3.4-r100. I’m using the version 0.0_p20131222 of libcxx and libcxxrt.

My code is working fine when optimizations are at low level (-O0 -O1 -Os) but when I use higher levels (-O2 -O3 -Ofast), my code does not link:

release/src/ast/Operator.cpp.o: In function eddic::ast::operator<<(std::__1::basic_ostream<char, std::__1::char_traits<char> >&, eddic::ast::Operator)': /home/wichtounet/dev/eddic/src/ast/Operator.cpp:15: undefined reference to std::__1::basic_ostream<char, std::__1::char_traits >& std::__1::operator<< <char, std::__1::char_traits, std::__1::allocator >(std::__1::basic_ostream<char, std::__1::char_traits >&, std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator > const&)’
clang: error: linker command failed with exit code 1 (use -v to see invocation)

I’m using clang++ to compile and link. I’m using -std=c++1y -stdlib=libc++ options.

The code in question does not seem to be the cause of the problem:

std::ostream& ast::operator<< (std::ostream& stream, ast::Operator op){
std::string value = “asd”;
return stream << value;
}

What I’m doing wrong ?

Could it be a problem in one of the optimizations ? (Between O2 and Os)

Thanks for any help, I’m kind of stuck on that for some time now.

Baptiste Wicht