I've found a very minor problem where a C++ error is detected for valid C++ code.
The code is:
struct A {
struct B;
};
struct A::B {
A::B& operator=(const A&) {
return *this; // <-- this is the line where the error is reported
}
};
The problem is reported as:
file: '...' severity: 'Error' message: 'a reference of type "A::B &" (not const-qualified) cannot be initialized with a value of type "A::B"' at: '...'
and disappears using B& operator=(const A&) as declaration.
Interesting. I'll forward this on to the compiler team. Thanks for reporting it.
This repros with the latest VS 2017 15.5 Preview 3 too. The issue goes away if the definition of B or the declaration of the operator= is moved into the definition A.
We've reported the bug to the VS C++ team internally, and also on the VS 2017 external site (https://developercommunity.visualstudio.com/content/problem/196646/invalid-c-intellisense-error-a-reference-of-type-a.html , although if that link doesn't work, it might be "Microsoft internal"). No ETA on a fix yet.
Hmm...the VS team "Won't Fixed" it -- more people will need to upvote the VS issue (or this one).
Most helpful comment
Hmm...the VS team "Won't Fixed" it -- more people will need to upvote the VS issue (or this one).