Vscode-cpptools: C++ error detected for valid C++ code

Created on 3 Nov 2017  路  4Comments  路  Source: microsoft/vscode-cpptools

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.

Language Service Visual Studio bug more votes needed

Most helpful comment

Hmm...the VS team "Won't Fixed" it -- more people will need to upvote the VS issue (or this one).

All 4 comments

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).

Was this page helpful?
0 / 5 - 0 ratings

Related issues

arl picture arl  路  3Comments

SkyRiderMike picture SkyRiderMike  路  3Comments

jrieken picture jrieken  路  3Comments

chrisckc picture chrisckc  路  3Comments

jyavenard picture jyavenard  路  3Comments