Closed GreenGary closed 4 years ago
@friedrichatgc : please do comment on GreenGary's potential fix. I am by dimensions not firm enough in both fmatvec and C++ to judge.
"inline const Vector<Ref,AT> operator()(const Range<Var,Var> &I) const;" in vector.h:281 and "inline const SquareMatrix<Ref,AT> operator()(const Range<Var,Var> &I) const;" in general_matrix.h:348 really have the same signature but different return types as noted by the error message.
According to https://en.cppreference.com/w/cpp/language/using_declaration regarding "using": "If the name is the name of an overloaded member function of the base class, all base class member functions with that name are introduced." the using statement brings in all operator()(......) overloads. And the next sentence "If the derived class already has a member with the same name, parameter list, and qualifications, the derived class member hides or overrides (doesn't conflict with) the member that is introduced from the base class" means that this seems to be a MSVC bug.
I checked all overloads of operator()(...) in matrix. Only operator()() is useful in vector. So I think the "using" statement is valid according to c++ but to much here. Hence your proposed fix is good and should replace the "using" statement not only for MSVC but also for gcc. Added a wrapper for other overloads is not needed.
Microsoft support found a workaround: "Swapping the order of the using declaration and the overloaded operator appears to be a workaround."
Fixed
Trying to get #5 done, I spotted an interesting, not trivial compile(er) error. Only MSVC (in all versions) complains about this, gcc and clang have no problem.
Problem: linear_algebra_double.cc(782) and linear_algebra_double.cc(891) raise error C3066. The called function
operator()(const Range<Var,Var> &I) const
is declared both inclass Vector<Ref,AT>
andMatrix<General,Ref,Ref,AT>
(with different return types). Vector derived from Matrix. Both functions are not virtual. The root cause is theusing Matrix<General, Ref, Ref, AT>::operator();
in vector.h, which pulls function nameoperator()
into Vector. MSVC now complains about multiple possible ways that an object of this type can be called with these arguments... I am not convinced, that this is really a bug in MSVC. Anyway, this should be fixed (for MSVC or in general)Potential Fix:
Here is a reproducer that can be used to play around e.g. with godbolt or whatever platofrm