This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c++/66197] New: c++1z generic function wrong type for auto


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66197

            Bug ID: 66197
           Summary: c++1z generic function wrong type for auto
           Product: gcc
           Version: 5.1.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: theonetruekenny at yahoo dot com
  Target Milestone: ---

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'.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]