[Bug c++/87531] [8/9 Regression] assignment operator does nothing if performed as a call via operator=
petschy at gmail dot com
gcc-bugzilla@gcc.gnu.org
Wed Dec 5 20:24:00 GMT 2018
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87531
petschy at gmail dot com changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |petschy at gmail dot com
--- Comment #7 from petschy at gmail dot com ---
After this fix, the following code doesn't compile:
template<typename T>
struct Ptr
{
Ptr& operator=(T* p_)
{
return operator=<T>(p_);
}
template<typename U>
Ptr& operator=(U* p_)
{
ptr = p_;
return *this;
}
T* ptr = nullptr;
};
$ g++-8.2.1 -Wall -std=c++11 -c 20181204-templated_opeq.cpp
20181204-templated_opeq.cpp: In member function ‘Foo<T>&
Foo<T>::operator=(T*)’:
20181204-templated_opeq.cpp:6:21: error: expected primary-expression before ‘>’
token
return operator=<T>(p_);
^
On the gcc-8-branch, the commit before the fix (a9a931e4) is OK. 7.3.1
(4c925b84) is OK. Tested on Debian Stretch, AMD64.
Is the above code invalid?
More information about the Gcc-bugs
mailing list