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

            Bug ID: 88485
           Summary: [9 regression] parse error on explicitly specialized
                    assignment call
           Product: gcc
           Version: 9.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: s...@li-snyder.org
  Target Milestone: ---

hi -

gcc9 rejects the following code:

-------------------------------------------------------------
template <class T> class Base {};
class Block : public Base<Block> {};

template<typename T>
class Foo
{
  template<typename Other>
  Block& operator=(const Base<Other>& other);

  Block& operator=(const Block& other)
  {
    return operator=<Block>(other);
  }
};
-------------------------------------------------------------
$ cc1plus -quiet -version x.cc
GNU C++14 (GCC) version 9.0.0 20181212 (experimental) (x86_64-pc-linux-gnu)
        compiled by GNU C version 9.0.0 20181212 (experimental), GMP version
6.1.2, MPFR version 3.1.6-p2, MPC version 1.0.2, isl version isl-0.16.1-GMP

GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
GNU C++14 (GCC) version 9.0.0 20181212 (experimental) (x86_64-pc-linux-gnu)
        compiled by GNU C version 9.0.0 20181212 (experimental), GMP version
6.1.2, MPFR version 3.1.6-p2, MPC version 1.0.2, isl version isl-0.16.1-GMP

GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
Compiler executable checksum: c0eebf4a7781166f39f275d6d099325f
x.cc: In member function ‘Block& Foo<T>::operator=(const Block&)’:
x.cc:12:27: error: expected primary-expression before ‘>’ token
   12 |     return operator=<Block>(other);
      |                           ^
-------------------------------------------------------------

The same code is accepted by both gcc 8.2.1 and clang 6.0.1.
The error also goes away if the class `Foo' is changed to be a non-template
class,
or if `operator=' is changed to a named method.

Reply via email to