Core dump after using -fshort-enums

Hello

Compiling with -fshort-enums causing memory fault

QCC -fshort-enums -w9 -g -o enum enum.cc

#include
#include

int main(int argc, char *argv[]) {
std::cout << “Welcome to the QNX” << std::endl;
return EXIT_SUCCESS;
}

What’s wrong?

I hope anybody knows this problem and can help me.

Thanks
Marek

PS
gdb:
This GDB was configured as “ntox86”…
Program terminated with signal 11, Segmentation fault.
Reading symbols from /usr/qnx632/target/qnx6/x86/lib/libcpp.so.3…done.
Loaded symbols for /usr/qnx632/target/qnx6/x86/lib/libcpp.so.3
Reading symbols from /usr/qnx632/target/qnx6/x86/lib/libc.so.2…done.
Loaded symbols for /usr/qnx632/target/qnx6/x86/lib/libc.so.2
#0 0x0804af74 in std::basic_ostream<char, std::char_traits >::_Sentry_base::_Sentry_base (this=0x8047a2c, _Ostr=@0x804e128)
at /usr/qnx632/target/qnx6/usr/include/cpp/ostream:76
76 _Myostr.rdbuf()->_Lock();
(gdb) back
#0 0x0804af74 in std::basic_ostream<char, std::char_traits >::_Sentry_base::_Sentry_base (this=0x8047a2c, _Ostr=@0x804e128)
at /usr/qnx632/target/qnx6/usr/include/cpp/ostream:76
#1 0x0804a774 in std::basic_ostream<char, std::char_traits >::sentry::sentry (this=0x8047a2c, _Ostr=@0x804e128)
at /usr/qnx632/target/qnx6/usr/include/cpp/ostream:93
#2 0x0804a2e6 in std::basic_ostream<char, std::char_traits > & std::operator<<<std::char_traits > (_Ostr=@0x804e128,
_Val=0x804bbd4 “Welcome to the QNX”) at /usr/qnx632/target/qnx6/usr/include/cpp/ostream:665
#3 0x0804a1bc in main (argc=1, argv=0x8047a8c) at enum.cc:5
(gdb) q

Because as the doc say you can’t use -fshort-enums. The c and c++ library were build with enum being 32bit, when you use that option the header file and the library (.so) don’t match anymore, cause havoc.

Thanks Where the doc say? I must read shared memory created with enum 16bit. I will replace enum with short.

Marek

That’s somewhere in the gcc documentation. I think what through gcc __attribute feature you could specify the size of enum for each individual type.