https://gcc.gnu.org/ml/gcc-help/2015-05/msg00066.html #include <iostream> auto add_1(auto a, auto b) { return a + b;} auto add_2 = [](auto a, auto b) { return a + b;}; int main() { std::cout << "a1: " << add_1(3.5, 4) << "\n" << "a2: " << add_1(3, 4.5) << "\n" << "a3: " << add_2(3.5, 4) << "\n" << "a4: " << add_2(3, 4.5) << "\n"; } This gives me: a1: 7.5 a2: 7 a3: 7.5 a4: 7.5 But the expected value for a2 would also be 7.5. This was with This is with a fedora 22/x86-64 machine. gcc version 5.1.1 20150422 (Red Hat 5.1.1-1) (GCC) According to the current spec: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2014/n3889.pdf 15 "A generic function is denoted by function declarator having auto or a concept-name as part of the type-specifier in its parameter-declaration-clause" 17 "All placeholder types introduced using the same concept-name have the same invented template parameter." It would appear that gcc is applying the rule from 17 even in the case of 'auto'.
This might be another symptom of https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64969
Indeed, this is also fixed in mainline. I'm adding a testcase and closing the bug.
Author: paolo Date: Tue Aug 4 17:22:05 2015 New Revision: 226591 URL: https://gcc.gnu.org/viewcvs?rev=226591&root=gcc&view=rev Log: 2015-08-04 Paolo Carlini <paolo.carlini@oracle.com> PR c++/66197 * g++.dg/cpp1z/abbrev2.C: New. 2015-08-04 Paolo Carlini <paolo.carlini@oracle.com> * g++.dg/cpp1z/static_assert-nomsg.C: Fix DejaGnu directive. Added: trunk/gcc/testsuite/g++.dg/cpp1z/abbrev2.C Modified: trunk/gcc/testsuite/ChangeLog trunk/gcc/testsuite/g++.dg/cpp1z/static_assert-nomsg.C
Done.