[cfe-dev] Interesting behaviour with UBSAN+libc++
İsmail Dönmez
ismail at donmez.ws
Thu Dec 4 05:21:33 PST 2014
I got some very simple code, dumbed down from a larger one:
[~]> cat wc.cpp
#include <iostream>
int wc() {
return 0;
}
int main()
{
std::cout << wc() << std::endl;
}
[~]> /opt/clang/bin/clang++ -stdlib=libc++ -fsanitize=undefined wc.cpp
[~]> ./a.out
/opt/clang/bin/../include/c++/v1/ostream:1034:14: runtime error: member
call on address 0x000000ef9858 which does not point to an object of type
'std::__1::basic_ios<char>'
0x000000ef9850: note: object is base class subobject at offset 8 within
object of type 'std::__1::basic_ostream<char, std::__1::char_traits<char> >'
00 00 00 00 40 a3 b9 c6 b1 7f 00 00 68 a3 b9 c6 b1 7f 00 00 02 10 00 00
00 00 00 00 06 00 00 00
^ ~~~~~~~~~~~~~~~~~~~~~~~
vptr for '<unknown>' base class of
'std::__1::basic_ostream<char, std::__1::char_traits<char> >'
/opt/clang/bin/../include/c++/v1/ios:734:41: runtime error: member call on
address 0x000000ef9858 which does not point to an object of type
'std::__1::ios_base'
0x000000ef9850: note: object is base class subobject at offset 8 within
object of type 'std::__1::basic_ostream<char, std::__1::char_traits<char> >'
00 00 00 00 40 a3 b9 c6 b1 7f 00 00 68 a3 b9 c6 b1 7f 00 00 02 10 00 00
00 00 00 00 06 00 00 00
^ ~~~~~~~~~~~~~~~~~~~~~~~
vptr for '<unknown>' base class of
'std::__1::basic_ostream<char, std::__1::char_traits<char> >'
0
Works fine if I link to libstdc++. clang is r223341.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20141204/eeba475e/attachment.html>
More information about the cfe-dev
mailing list