This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Byte Alignment 1 for Code using STL
- To: gcc at gcc dot gnu dot org
- Subject: Byte Alignment 1 for Code using STL
- From: "David St-Onge" <david_stonge at hotmail dot com>
- Date: Mon, 19 Jun 2000 14:39:27 CEST
Hi!
I'm porting some code from Windows NT 4.0 to Linux SuSE 6.3, Pentium to
Pentium. The whole project compiles on Windows with byte alignment 1 in the
project settings of Visual Studio. To get the same alignment on Linux, I
added '#pragma pack(1)' a the beginning of all source file (both .cpp and
.h). The problem I have now, is that some of the STL functions generates
Segmentation Faults. Any idea what I do wrong???
BTW, I compile with the following instruction:
g++ -fhonor-std -g -DHANDLE_SYSV_PRAGMA
Thanks for your help!
David
EXAMPLE OF THE PROBLEM:
(name is a std::string, id is an unsigned long)
=> insert(make_pair(name, id));
(down in the call stack:)
template <class _T1, class _T2>
struct pair {
typedef _T1 first_type;
typedef _T2 second_type;
_T1 first;
_T2 second;
pair() : first(_T1()), second(_T2()) {}
pair(const _T1& __a, const _T2& __b) : first(__a), second(__b) {}
#ifdef __STL_MEMBER_TEMPLATES
template <class _U1, class _U2>
=> pair(const pair<_U1, _U2>& __p) : first(__p.first), second(__p.second)
{}
#endif
};
(down in the call stack:)
bool
_M_is_leaked() const
=> { return static_cast<_Signed_state_type>(_M_state) < 0; }
Program received signal SIGSEGV, Segmentation fault.
std::basic_string<char, std::char_traits<char>, std::allocator<char>
>::basic_string (this=0xbfffedc4, __str=@0xbfffedb8)
at /usr/gnu/gcc-2.95.2/libstdc++/bits/basic_string.h:152
________________________________________________________________________
Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com