[問題] static成員變數大小
開發平台(Platform): (Ex: VC++, GCC, Linux, ...)
linux
問題(Question):
我有一個class XXX 裡面有個static成員
static const size_t BUFFERSIZE = 1024*1024*100;
還有一個陣列
uint8_t mBuffer[ BUFFERSIZE ];
執行時
如果改成BUFFERSIZE=1024*1024就不會當
1024*1024*100就會當
1024*1024*3不會當
錯誤結果(Wrong Output):
66 analysisFile( inputFile, inputFile + "_analysis" );
(gdb) s
std::operator+<char, std::char_traits<char>, std::allocator<char> >
(__lhs=..., __rhs=0x4056f2 "_analysis") at
/linux/depot/gcc-4.5.2/bin/../lib/gcc/x86_64-redhat-linux/4.5.2/../../../../include/c++/4.5.2/bits/basic_string.h:2303
2303 basic_string<_CharT, _Traits, _Alloc> __str(__lhs);
(gdb) n
2304 __str.append(__rhs);
(gdb) n
2306 }
(gdb) n
Program received signal SIGSEGV, Segmentation fault.
0x0000000000402127 in analysisFile (aInputFileName=Cannot access memory at
address 0x7fb9bfea58
) at Analysisor.cpp:50
50 {
(gdb)
當掉的地方gdb顯示是analysisFile函式的左括號
analysisFile中會建立一個XXX物件
但不知道為什麼會當在左括號處??
而且只要系統給100MB就會當 要如何知道系統可提供多少大小呢?
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 220.135.140.149
※ 編輯: Arton0306 來自: 220.135.140.149 (11/04 00:24)
→
11/04 00:25, , 1F
11/04 00:25, 1F
→
11/04 00:26, , 2F
11/04 00:26, 2F
→
11/04 00:26, , 3F
11/04 00:26, 3F
→
11/04 00:27, , 4F
11/04 00:27, 4F
→
11/04 00:28, , 5F
11/04 00:28, 5F
→
11/04 00:28, , 6F
11/04 00:28, 6F
→
11/04 23:00, , 7F
11/04 23:00, 7F
C_and_CPP 近期熱門文章
PTT數位生活區 即時熱門文章