https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69016
Bug ID: 69016 Summary: In C++14 standard, function with auto as return and arguments returns result with the datatype of first argument only Product: gcc Version: 4.9.2 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: emailstorbala at gmail dot com Target Milestone: --- Hi Team, I am using gcc/g++ 4.9.2 version in Debian 8.2. I tried to compile the below code using the compiler option: g++ -std=c++14 -s -O3 test.cpp -o test ---------------------------------------------------- #include <iostream> using namespace std; auto GetSum(auto a, auto b) { return (a + b); } int main() { auto temp = GetSum(10, 20.5); cout << "The sum is " << temp << endl; return 0; } ---------------------------------------------------- Result: The sum is 30 If the code is changed to ---------------------------------------------------- #include <iostream> using namespace std; auto GetSum(auto a, auto b) { return (a + b); } int main() { auto temp = GetSum(10.5, 20); cout << "The sum is " << temp << endl; return 0; } ---------------------------------------------------- Result: The sum is 30.5 Issue: The function GetSum() returns value of the first data type only rather than the final value's datatype. (Even if I set - auto GetSum(auto a, auto b) -> double) Please let me know if I am doing anything wrong.