[Bug c++/88762] New: C++17 Deduction guide and operator expression produces missing template argument error

pkeir at outlook dot com gcc-bugzilla@gcc.gnu.org
Tue Jan 8 18:10:00 GMT 2019


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

            Bug ID: 88762
           Summary: C++17 Deduction guide and operator expression produces
                    missing template argument error
           Product: gcc
           Version: 9.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: pkeir at outlook dot com
  Target Milestone: ---

Created attachment 45383
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=45383&action=edit
C++ file which produces the error.

I believe the code below/attached should compile with:

g++ -c -std=c++17 gcc-deduction-expr.cpp

The code is already reduced, but I also tried changing the operator for a
method; and only using operator+ once; but the error disappears in both cases.
The code compiles with Clang. Here is the error:

error: missing template arguments after ‘Foo’
   (Foo{x} + Foo{y}) + Foo{z};
    ^~~

The code:

template <typename T>
struct Foo {
  Foo operator+(Foo &&f) { return f; }
  T &x;
};
template <typename T> Foo(T) -> Foo<T>;

void zod()
{
  int x,y,z;
  (Foo{x} + Foo{y}) + Foo{z};
}


More information about the Gcc-bugs mailing list