C++
Runtime options...
Runtime options...
Runtime options...
Runtime options...
Runtime options...
Runtime options...
Runtime options...
Runtime options...
Runtime options...
Runtime options...
Runtime options...
Runtime options...
Runtime options...
Runtime options...
Runtime options...
Runtime options...
Runtime options...
Runtime options...
Runtime options...
Runtime options...
Runtime options...
Runtime options...
Runtime options...
Runtime options...
Runtime options...
Runtime options...
Runtime options...
Runtime options...
Runtime options...
Runtime options...
Runtime options...
Runtime options...
Runtime options...
Runtime options...
Runtime options...
Runtime options...
Runtime options...
Runtime options...
Runtime options...
Runtime options...
Runtime options...
Runtime options...
Runtime options...
Runtime options...
Runtime options...
Runtime options...
Runtime options...
Runtime options...
Runtime options...
Runtime options...
Runtime options...
Runtime options...
Runtime options...
Runtime options...
Runtime options...
Runtime options...
Runtime options...
Runtime options...
Runtime options...
Runtime options...
Runtime options...
Runtime options...
Runtime options...
Runtime options...
Runtime options...
Runtime options...
Runtime options...
Runtime options...
Runtime options...
Runtime options...
Runtime options...
Runtime options...
Runtime options...
Runtime options...
Runtime options...
Runtime options...
Runtime options...
Runtime options...
Runtime options...
Runtime options...
Runtime options...
Runtime options...
Runtime options...
Runtime options...
Runtime options...
Runtime options...
Runtime options...
Runtime options...
Runtime options...
Runtime options...
Runtime options...
Runtime options...
Runtime options...
Runtime options...
Runtime options...
Runtime options...
Runtime options...
Runtime options...
Runtime options...
Runtime options...
Runtime options...
Runtime options...
Runtime options...
Runtime options...
Runtime options...
Runtime options...
Runtime options...
Runtime options...
Runtime options...
Runtime options...
Runtime options...
Runtime options...
Runtime options...
Runtime options...
Runtime options...
Runtime options...
Runtime options...
Runtime options...
Runtime options...
Runtime options...
Runtime options...
Runtime options...
Runtime options...
Runtime options...
Runtime options...
Runtime options...
Runtime options...
Runtime options...
Runtime options...
Runtime options...
Runtime options...
Runtime options...
Runtime options...
Runtime options...
Runtime options...
Runtime options...
Runtime options...
Runtime options...
Runtime options...
Runtime options...
Runtime options...
Runtime options...
Runtime options...
Runtime options...
Runtime options...
Runtime options...
Runtime options...
Runtime options...
Runtime options...
Runtime options...
Runtime options...
Runtime options...
Runtime options...
Runtime options...
Runtime options...
Runtime options...
Runtime options...
Runtime options...
Runtime options...
Runtime options...
Runtime options...
Runtime options...
Runtime options...
Runtime options...
Runtime options...
Runtime options...
Runtime options...
Runtime options...
Runtime options...
Runtime options...
Runtime options...
Runtime options...
Runtime options...
Runtime options...
Runtime options...
Runtime options...
Runtime options...
Runtime options...
Runtime options...
Runtime options...
Runtime options...
Runtime options...
Runtime options...
Runtime options...
Runtime options...
Runtime options...
Runtime options...
Runtime options...
Runtime options...
Runtime options...
Runtime options...
Runtime options...
Runtime options...
Runtime options...
Runtime options...
Runtime options...
Runtime options...
Runtime options...
Runtime options...
Runtime options...
Runtime options...
Runtime options...
Runtime options...
Runtime options...
Runtime options...
Runtime options...
Runtime options...
Runtime options...
Runtime options...
Runtime options...
Runtime options...
Runtime options...
Runtime options...
Runtime options...
Runtime options...
Runtime options...
Runtime options...
- voluntas
- @ignis_fatuus
- ブン
- 清楚なC++メイドBOT
- @tzik_tack
- 長谷川一輝
- wraith13
- @jj1bdx
- @cpp_akira
- 安藤敏彦
- @srz_zumix
- Siv3D
- takezoh
- まろ
- @okdshin
- @hnokx
- @ishidakei
- @take_cheeze
- TAKEI Yuya
- @mumumu
- 黒澤 亮二
- I (@wx257osn2)
- @gnaggnoyil
- @mandel59
- Tommy6
- イズカワタカノブ
- @tyottyoworks
- ___shanon
- わたやん
- @KorekaraSEDB
- @kariya_mitsuru
- @ciniml
- @beam2d
- @grafi_tt
- @nekketsuuu
- LouiS0616
- @volanja
- 大鎌広
x
22
1
2
3
struct hoge {
4
hoge() { std::cout << "create hoge " << this << std::endl; }
5
~hoge() { std::cout << "delete hoge " << this << std::endl; }
6
};
7
8
int main(void) {
9
std::cout << "--- new ---" << std::endl;
10
hoge* a = new hoge;
11
std::cout << "--- delete ---" << std::endl;
12
delete a;
13
std::cout << "--- new[] ---" << std::endl;
14
hoge* b = new hoge[2];
15
std::cout << "--- delete[] ---" << std::endl;
16
delete[] b;
17
std::cout << "--- new[] ---" << std::endl;
18
hoge* c = new hoge[2];
19
std::cout << "--- delete ---" << std::endl;
20
delete c;
21
}
22
$ g++ prog.cc -Wall -Wextra -std=c++98 -pedantic
Start
--- new --- create hoge 0x22fac30 --- delete --- delete hoge 0x22fac30 --- new[] --- create hoge 0x22fac38 create hoge 0x22fac39 --- delete[] --- delete hoge 0x22fac39 delete hoge 0x22fac38 --- new[] --- create hoge 0x22fac38 create hoge 0x22fac39 --- delete --- delete hoge 0x22fac38
*** Error in `./prog.exe': munmap_chunk(): invalid pointer: 0x00000000022fac38 *** ======= Backtrace: ========= /lib/x86_64-linux-gnu/libc.so.6(+0x777e5)[0x7fafcb4967e5] /lib/x86_64-linux-gnu/libc.so.6(cfree+0x1a8)[0x7fafcb4a3698] ./prog.exe[0x400c62] /lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xf0)[0x7fafcb43f830] ./prog.exe[0x4009f9] ======= Memory map: ======== 00400000-00402000 r-xp 00000000 fd:03 9450729 /home/jail/prog.exe 00601000-00602000 rw-p 00001000 fd:03 9450729 /home/jail/prog.exe 022e8000-0231a000 rw-p 00000000 00:00 0 [heap] 7fafcb41f000-7fafcb5df000 r-xp 00000000 fd:03 147125 /lib/x86_64-linux-gnu/libc-2.23.so 7fafcb5df000-7fafcb7df000 ---p 001c0000 fd:03 147125 /lib/x86_64-linux-gnu/libc-2.23.so 7fafcb7df000-7fafcb7e3000 r--p 001c0000 fd:03 147125 /lib/x86_64-linux-gnu/libc-2.23.so 7fafcb7e3000-7fafcb7e5000 rw-p 001c4000 fd:03 147125 /lib/x86_64-linux-gnu/libc-2.23.so 7fafcb7e5000-7fafcb7e9000 rw-p 00000000 00:00 0 7fafcb7e9000-7fafcb800000 r-xp 00000000 fd:03 494118 /opt/wandbox/gcc-10.1.0/lib64/libgcc_s.so.1 7fafcb800000-7fafcb9ff000 ---p 00017000 fd:03 494118 /opt/wandbox/gcc-10.1.0/lib64/libgcc_s.so.1 7fafcb9ff000-7fafcba00000 rw-p 00016000 fd:03 494118 /opt/wandbox/gcc-10.1.0/lib64/libgcc_s.so.1 7fafcba00000-7fafcbb08000 r-xp 00000000 fd:03 147128 /lib/x86_64-linux-gnu/libm-2.23.so 7fafcbb08000-7fafcbd07000 ---p 00108000 fd:03 147128 /lib/x86_64-linux-gnu/libm-2.23.so 7fafcbd07000-7fafcbd08000 r--p 00107000 fd:03 147128 /lib/x86_64-linux-gnu/libm-2.23.so 7fafcbd08000-7fafcbd09000 rw-p 00108000 fd:03 147128 /lib/x86_64-linux-gnu/libm-2.23.so 7fafcbd09000-7fafcbec5000 r-xp 00000000 fd:03 494142 /opt/wandbox/gcc-10.1.0/lib64/libstdc++.so.6.0.28 7fafcbec5000-7fafcc0c5000 ---p 001bc000 fd:03 494142 /opt/wandbox/gcc-10.1.0/lib64/libstdc++.so.6.0.28 7fafcc0c5000-7fafcc0d0000 r--p 001bc000 fd:03 494142 /opt/wandbox/gcc-10.1.0/lib64/libstdc++.so.6.0.28 7fafcc0d0000-7fafcc0d3000 rw-p 001c7000 fd:03 494142 /opt/wandbox/gcc-10.1.0/lib64/libstdc++.so.6.0.28 7fafcc0d3000-7fafcc0d6000 rw-p 00000000 00:00 0 7fafcc0d6000-7fafcc0ee000 r-xp 00000000 fd:03 147112 /lib/x86_64-linux-gnu/libpthread-2.23.so 7fafcc0ee000-7fafcc2ed000 ---p 00018000 fd:03 147112 /lib/x86_64-linux-gnu/libpthread-2.23.so 7fafcc2ed000-7fafcc2ee000 r--p 00017000 fd:03 147112 /lib/x86_64-linux-gnu/libpthread-2.23.so 7fafcc2ee000-7fafcc2ef000 rw-p 00018000 fd:03 147112 /lib/x86_64-linux-gnu/libpthread-2.23.so 7fafcc2ef000-7fafcc2f3000 rw-p 00000000 00:00 0 7fafcc2f3000-7fafcc319000 r-xp 00000000 fd:03 147111 /lib/x86_64-linux-gnu/ld-2.23.so 7fafcc509000-7fafcc50f000 rw-p 00000000 00:00 0 7fafcc517000-7fafcc518000 rw-p 00000000 00:00 0 7fafcc518000-7fafcc519000 r--p 00025000 fd:03 147111 /lib/x86_64-linux-gnu/ld-2.23.so 7fafcc519000-7fafcc51a000 rw-p 00026000 fd:03 147111 /lib/x86_64-linux-gnu/ld-2.23.so 7fafcc51a000-7fafcc51b000 rw-p 00000000 00:00 0 7ffc309e6000-7ffc30a07000 rw-p 00000000 00:00 0 [stack] 7ffc30a9b000-7ffc30a9d000 r--p 00000000 00:00 0 [vvar] 7ffc30a9d000-7ffc30a9f000 r-xp 00000000 00:00 0 [vdso] ffffffffff600000-ffffffffff601000 r-xp 00000000 00:00 0 [vsyscall]
Aborted
Finish