You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It is possible that I misunderstand C++ order of execution but I receive an incomprehensible (to me) uninitialized data error with following code. I am using clang 4.0 on Ubuntu 17.04
$ cat foo.cpp
#include
#include
const char * foo[] =
{
"AAA",
"BBB"
};
const int numfoo = sizeof(foo)/sizeof(const char *);
typedef std::map<int, int> other_map;
class bar : other_map
{
public:
bar(const char * b[], int numb)
{
for (int i = 0; i < numb; i++)
{
std::cout << b[i] << std::endl;
}
}
};
bar c(foo, numfoo);
int main(int argc, char** argv) {
return 0;
}
$ clang -g -fsanitize=memory foo.cpp -lstdc++
$ ./a.out
Uninitialized bytes in __interceptor_memcmp at offset 236 inside [0x7ffc47b0e0c0, 256)
==19320==WARNING: MemorySanitizer: use-of-uninitialized-value
#0 0x7fe423328e75 in std::ctype::_M_widen_init() const (/usr/lib/x86_64-linux-gnu/libstdc++.so.6+0xb6e75) #1 0x7fe423384b87 in std::basic_ostream<char, std::char_traits >& std::endl<char, std::char_traits >(std::basic_ostream<char, std::char_traits >&) (/usr/lib/x86_64-linux-gnu/libstdc++.so.6+0x112b87) #2 0x490b41 in bar::bar(char const**, int) /home/nks/foo.cpp:20:31 #3 0x41a624 in __cxx_global_var_init.2 /home/nks/foo.cpp:25:5 #4 0x41a67d in _GLOBAL__sub_I_foo.cpp /home/nks/foo.cpp #5 0x49209c in __libc_csu_init (/home/nks/a.out+0x49209c) #6 0x7fe42238137f in __libc_start_main /build/glibc-cxyGtm/glibc-2.24/csu/../csu/libc-start.c:247 #7 0x41a6a9 in _start (/home/nks/a.out+0x41a6a9)
Hi,
It is possible that I misunderstand C++ order of execution but I receive an incomprehensible (to me) uninitialized data error with following code. I am using clang 4.0 on Ubuntu 17.04
$ cat foo.cpp
#include
#include
const char * foo[] =
{
"AAA",
"BBB"
};
const int numfoo = sizeof(foo)/sizeof(const char *);
typedef std::map<int, int> other_map;
class bar : other_map
{
public:
bar(const char * b[], int numb)
{
for (int i = 0; i < numb; i++)
{
std::cout << b[i] << std::endl;
}
}
};
bar c(foo, numfoo);
int main(int argc, char** argv) {
return 0;
}
$ clang -g -fsanitize=memory foo.cpp -lstdc++
$ ./a.out
Uninitialized bytes in __interceptor_memcmp at offset 236 inside [0x7ffc47b0e0c0, 256)
==19320==WARNING: MemorySanitizer: use-of-uninitialized-value
#0 0x7fe423328e75 in std::ctype::_M_widen_init() const (/usr/lib/x86_64-linux-gnu/libstdc++.so.6+0xb6e75)
#1 0x7fe423384b87 in std::basic_ostream<char, std::char_traits >& std::endl<char, std::char_traits >(std::basic_ostream<char, std::char_traits >&) (/usr/lib/x86_64-linux-gnu/libstdc++.so.6+0x112b87)
#2 0x490b41 in bar::bar(char const**, int) /home/nks/foo.cpp:20:31
#3 0x41a624 in __cxx_global_var_init.2 /home/nks/foo.cpp:25:5
#4 0x41a67d in _GLOBAL__sub_I_foo.cpp /home/nks/foo.cpp
#5 0x49209c in __libc_csu_init (/home/nks/a.out+0x49209c)
#6 0x7fe42238137f in __libc_start_main /build/glibc-cxyGtm/glibc-2.24/csu/../csu/libc-start.c:247
#7 0x41a6a9 in _start (/home/nks/a.out+0x41a6a9)
SUMMARY: MemorySanitizer: use-of-uninitialized-value (/usr/lib/x86_64-linux-gnu/libstdc++.so.6+0xb6e75) in std::ctype::_M_widen_init() const
Exiting
$ clang --version
clang version 4.0.0-1ubuntu1 (tags/RELEASE_400/rc1)
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/bin
The text was updated successfully, but these errors were encountered: