C++
- @Linda_pp
- 清楚なC++メイドBOT
- 長谷川一輝
- @jj1bdx
- 安藤敏彦
- Siv3D
- @hnokx
- @ishidakei
- TAKEI Yuya
- I (@wx257osn2)
- Tommy6
- @nekketsuuu
- LouiS0616
- @volanja
- 大鎌広
- むてら
- ガチKGB
- 三重野賢人
x
1
int& test1(){
2
int a = 10;
3
int& res = a;
4
return res;
5
}
6
int& test2(){
7
int a = 10;
8
return a;
9
}
$ clang++ prog.cc -Wall -Wextra -std=gnu++2a
Start
prog.cc:4:12: warning: reference to stack memory associated with local variable 'a' returned [-Wreturn-stack-address] return res; ^~~ prog.cc:3:10: note: binding reference variable 'res' here int& res = a; ^ ~ prog.cc:8:12: warning: reference to stack memory associated with local variable 'a' returned [-Wreturn-stack-address] return a; ^ 2 warnings generated. /usr/lib/gcc/x86_64-linux-gnu/5.5.0/../../../x86_64-linux-gnu/crt1.o: In function `_start': (.text+0x20): undefined reference to `main' clang-11: error: linker command failed with exit code 1 (use -v to see invocation)
1
Finish