GCC没有警告,虽然它应该

Hex*_*Hex 2 c gcc warnings compiler-warnings

我有一个非常简单的Hello World程序,它在main()函数的末尾没有返回.如果我理解正确,这应该抛出一个Wreturn类型的警告,但是当我编译它时,根本没有给出输出.它简单地编译并完成.

程序:

#include <stdio.h>
int main() {
  printf("Hello World!\n");
}
Run Code Online (Sandbox Code Playgroud)

编译命令:

gcc -Wall -Wextra -o hello.o hello.c
Run Code Online (Sandbox Code Playgroud)

我也特意尝试了这个Wreturn-type选项.

在Manjaro 18.0.0与GCC 8.2.1

pmg*_*pmg 6

使用

gcc -std=c89 -pedantic ...
Run Code Online (Sandbox Code Playgroud)

因为在C99 1 main()中不需要return 0;.好像在右大括号之前有一个就好了.