Issue |
117697
|
Summary |
Incorrect Runtime Result with Function Overloading (Correct with gcc)
|
Labels |
new issue
|
Assignees |
|
Reporter |
lfeng14
|
# Title: Incorrect Runtime Result with Function Overloading (Correct with gcc)
When compiling with llvm, the runtime result is incorrect. The minimal code example is as follows:
```cpp
// main.cpp
#include <iostream>
#include <stdio.h>
#include "file.h"
int abc(char* a, char* b, bool c){
return 1;
}
int abc(bool a, bool b, char* c){
return 2;
}
int main(){
printf("%d\n",abc("his" ,"sophic"));
return 0;
}
// file.h
int abc(char* a, char* b, bool c=false);
int abc(bool a, bool b, char* c="his");
```
The build commands are as follows:
For llvm: `clang++ -o llvm_output main.cpp`
For gcc: `g++ -o gcc_output main.cpp`
When compiling with gcc, the runtime result is correct,result is 1, but clang result is 2.
It seems there is a problem with llvm's handling of function overloading that leads to incorrect runtime behavior compared to gcc.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs