4 ms·
If you use GCC, enable -Wall and you'll get the diagnostic you want: /tmp/cp.c: In function 'main': /tmp/cp.c:4:1: warning: control reaches end of non-
by comex 5y ago
If you use GCC, enable -Wall and you'll get the diagnostic you want:
/tmp/cp.c: In function 'main':
/tmp/cp.c:4:1: warning: control reaches end of non-void function [-Wreturn-type]
4 | }
| ^
If you use Clang, there is no diagnostic even with -Wall (or even -Weverything), but it looks like Clang always implements the implicit `return 0;` from C99 regardless of the `-std` setting.
- kevinoid 5y agoTo clarify, gcc -Wall only produces the warning with -std=c89/gnu89 (or GCC < 5 without -std=c99/gnu99). As with clang, it implements the implicit `return 0;` for C99 and later. Example: https://godbolt.org/z/Y7Wx5Y89q https://godbolt.org/z/Y7Wx5Y89q