View topic - Core dump after using -fshort-enums

Core dump after using -fshort-enums

anything that doesn't fit to other groups.

Core dump after using -fshort-enums

Postby waszcz » Thu May 06, 2010 2:49 pm

Hello

Compiling with -fshort-enums causing memory fault

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

#include <cstdlib>
#include <iostream>

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<char> >::_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<char> >::_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<char> >::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<char> > & std::operator<<<std::char_traits<char> > (_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
waszcz
New Member
 
Posts: 6
Joined: Wed Apr 21, 2004 9:15 am

RE: Core dump after using -fshort-enums

Postby mario » Sat May 08, 2010 10:56 am

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.
mario
QNX Master
 
Posts: 4132
Joined: Sun Sep 01, 2002 1:04 am

Postby waszcz » Sat May 08, 2010 11:35 pm

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

Marek
waszcz
New Member
 
Posts: 6
Joined: Wed Apr 21, 2004 9:15 am

Postby mario » Mon May 10, 2010 11:41 am

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.
mario
QNX Master
 
Posts: 4132
Joined: Sun Sep 01, 2002 1:04 am


Return to General Programming

Who is online

Users browsing this forum: No registered users and 2 guests