Issue 119953
Summary Clang compiles an invalid program normally
Labels clang
Assignees
Reporter ZY546
    https://godbolt.org/z/jETK87bq7
```c
int func_2();  //note: previous declaration of 'func_2' with type 'int(void)'
int func_1() { return func_2();}
int func_2(int a) { //error: conflicting types for 'func_2'; have 'int(int)'
    return 8;
}
int main() {
  return func_1();
}
```

Clang compiles the program normally, and the resulting program can be executed.


Expected behavior (like gcc):
```
Could not execute the program

Build failed

Compiler returned: 1
Compiler stderr

<source>:4:5: error: conflicting types for 'func_2'; have 'int(int)'
    4 | int func_2(int a) {
      | ^~~~~~
<source>:2:5: note: previous declaration of 'func_2' with type 'int(void)'
    2 | int func_2();
      |     ^~~~~~
```
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to