C
- @Linda_pp
- 清楚なC++メイドBOT
- 長谷川一輝
- @jj1bdx
- 安藤敏彦
- Siv3D
- @hnokx
- @ishidakei
- TAKEI Yuya
- I (@wx257osn2)
- Tommy6
- @nekketsuuu
- LouiS0616
- @volanja
- 大鎌広
- むてら
- ガチKGB
- 三重野賢人
x
13
1
2
3
int* fun() {
4
int x = 43;
5
int* ret = &x;
6
return ret;
7
}
8
9
int main() {
10
int* r = fun();
11
printf("%d", *r);
12
return 0;
13
}
$ gcc prog.c -Wall -Wextra -O2 -march=native -std=c99 -pedantic
Start
prog.c: In function 'fun': prog.c:6:12: warning: function returns address of local variable [-Wreturn-local-addr] 6 | return ret; | ^~~ prog.c:4:9: note: declared here 4 | int x = 43; | ^ prog.c: In function 'main': prog.c:11:5: warning: 'x' is used uninitialized in this function [-Wuninitialized] 11 | printf("%d", *r); | ^~~~~~~~~~~~~~~~
0
0
Finish