यह प्रश्न my question की निरंतरता है।std :: वेक्टर <std::string> क्रैश
यहां समस्याग्रस्त कोड है।
आह:
#include <string>
#include <vector>
std::vector<std::string> foo();
a.cpp
#include "a.h"
std::vector<std::string> foo()
{
std::vector<std::string> v;
return v;
}
और अंत में main.cpp:
#include "a.h"
#include <iostream>
int main()
{
std::vector<std::string> s = foo();
return 0;
}
निम्नलिखित के रूप में संकलन (main.cpp एसटीएल डिबगिंग ध्वज के साथ संकलित किया गया है) :
g++ -c a.cpp
g++ -D_GLIBCXX_DEBUG main.cpp a.o
जब a.out, चलने वाली प्रक्रिया दुर्घटनाओं:
Core was generated by `./a.out'.
Program terminated with signal 11, Segmentation fault.
#0 0x00007fe355998c43 in __gnu_debug::_Safe_iterator_base::_M_detach_single()() from /usr/lib64/libstdc++.so.6
(gdb) bt
#0 0x00007fe355998c43 in __gnu_debug::_Safe_iterator_base::_M_detach_single()() from /usr/lib64/libstdc++.so.6
#1 0x00007fe355999ebc in __gnu_debug::_Safe_sequence_base::_M_detach_all()() from /usr/lib64/libstdc++.so.6
#2 0x0000000000400cac in __gnu_debug::_Safe_sequence_base::~_Safe_sequence_base()()
#3 0x0000000000400cc6 in __gnu_debug::_Safe_sequence<std::__debug::vector<std::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::basic_string<char, std::char_traits<char>, std::allocator<char> > > > >::~_Safe_sequence()()
#4 0x0000000000400ce7 in std::__debug::vector<std::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::basic_string<char, std::char_traits<char>, std::allocator<char> > > >::~vector()()
#5 0x0000000000400c35 in main()
मेरे जीसीसी:
Using built-in specs.
Target: x86_64-suse-linux
Configured with: ../configure --prefix=/usr --infodir=/usr/share/info --mandir=/usr/share/man --libdir=/usr/lib64 --libexecdir=/usr/lib64 --enable-languages=c,c++,objc,fortran,obj-c++,java,ada --enable-checking=release --with-gxx-include-dir=/usr/include/c++/4.4 --enable-ssp --disable-libssp --with-bugurl=http://bugs.opensuse.org/ --with-pkgversion='SUSE Linux' --disable-libgcj --disable-libmudflap --with-slibdir=/lib64 --with-system-zlib --enable-__cxa_atexit --enable-libstdcxx-allocator=new --disable-libstdcxx-pch --enable-version-specific-runtime-libs --program-suffix=-4.4 --enable-linux-futex --without-system-libunwind --with-arch-32=i586 --with-tune=generic --build=x86_64-suse-linux
Thread model: posix
gcc version 4.4.1 [gcc-4_4-branch revision 150839] (SUSE Linux)
यह भी मैं समझता हूं।तो, आप मेरे प्रश्न http://stackoverflow.com/questions/4764048/stl-and-release-debug-library-mess के उत्तरों पर टिप्पणी कैसे करेंगे। क्या मैं जवाबों को गलत नहीं समझता या मेरा प्रश्न स्पष्ट/सही नहीं है? – dimba
स्पष्ट होने के लिए, सामान्य रूप से, झंडे को एक बार और सभी के लिए सेट किया जाना चाहिए और उन फ़ाइलों के पूरे सेट पर लगातार लागू होना चाहिए जिन्हें आप संकलित करना चाहते हैं। –
@Matthieu क्या आप – dimba