microsoft / microsoft/vscode-cpptools

Cannot deduce class template arguments

Offen
#12,299 1 Kommentar 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Dieses Issue hat noch niemand übernommen.

bug Language Service Visual Studio
Vorherrschende Sprache
TypeScript
Sterne
6.2k
Forks
1.7k
Ø Merge
14 Std. 46 Min.
Gemergte PRs (30 T.)
61

Beschreibung

Environment

Version: 1.89.0
Commit: b58957e67ee1e712cebf466b995adf4c5307b2bd
Date: 2024-05-01T02:08:25.066Z
Electron: 28.2.8
ElectronBuildId: 27744544
Chromium: 120.0.6099.291
Node.js: 18.18.2
V8: 12.0.267.19-electron.0
OS: Linux x64 6.6.30

  • C/C++ Extension Version:
    v1.20.5
Bug Summary and Steps to Reproduce

Steps to reproduce:

  1. Put the following code into a file foo.cpp.
  2. Apply the below c_cpp_properties.json to set the "cppStandard": "gnu++20".
struct EndOfScan
{
    bool loop;
    constexpr EndOfScan(bool l) : loop(l){};
};

struct OverrideCR
{
    int ormask;
    int andmask;
    constexpr OverrideCR(int a, int o) : ormask(o), andmask(a){};
    constexpr OverrideCR() : ormask(0), andmask(-1){};
};

constexpr EndOfScan Stop(true);
constexpr OverrideCR Override;

template <typename TInstr, typename TNext>
struct Scan
{
    TInstr i;
    TNext n;

    template <class... Cs>
    constexpr Scan(TInstr _i, Cs... cs) : i(_i), n(cs...){};
};

template <>
struct Scan<EndOfScan, void>
{
    EndOfScan i;
    constexpr Scan(EndOfScan eos) : i(eos){};
};

template <class... Cs>
Scan(EndOfScan e) -> Scan<EndOfScan, void>;

template <class C, class... Cs>
Scan(C c, Cs... cs) -> Scan<C, decltype(Scan{cs...})>;

extern const Scan test = {Override, Stop};

Expected behavior:

There should be no error squiggles and nothing listed in the Problems tab.

Actual behavior:

Scan test is underline as error and the Problems tab has the error cannot deduce class template arguments (as well as a follow up error that's a result from the inability to deduce the template parameters).

Configuration and Logs
{
    "configurations": [
        {
            "name": "Linux",
            "includePath": [
                "${workspaceFolder}/**"
            ],
            "defines": [],
            "compilerPath": "/usr/bin/gcc",
            "cStandard": "c17",
            "cppStandard": "gnu++20",
            "intelliSenseMode": "linux-gcc-x64"
        }
    ],
    "version": 4
}
-------- Diagnostics - 5/13/2024, 9:33:39 PM
Version: 1.20.5
Current Configuration:
{
    "name": "Linux",
    "includePath": [
        "/tmp/bug/**"
    ],
    "defines": [],
    "compilerPath": "/usr/bin/gcc",
    "cStandard": "c17",
    "cppStandard": "gnu++20",
    "intelliSenseMode": "linux-gcc-x64",
    "compilerPathIsExplicit": true,
    "cStandardIsExplicit": true,
    "cppStandardIsExplicit": true,
    "intelliSenseModeIsExplicit": true,
    "compilerPathInCppPropertiesJson": "/usr/bin/gcc",
    "mergeConfigurations": false,
    "browse": {
        "path": [
            "/tmp/bug/**",
            "${workspaceFolder}"
        ],
        "limitSymbolsToIncludedHeaders": true
    }
}
cpptools version (native): 1.20.5.0
Translation Unit Mappings:
[ /tmp/bug/foo.cpp - source TU]:
Translation Unit Configurations:
[ /tmp/bug/foo.cpp ]:
    Process ID: 18390
    Memory Usage: 16 MB
    Compiler Path: /usr/bin/gcc
    Includes:
        /usr/include/c++/9
        /usr/include/x86_64-linux-gnu/c++/9
        /usr/include/c++/9/backward
        /usr/lib/gcc/x86_64-linux-gnu/9/include
        /usr/local/include
        /usr/include/x86_64-linux-gnu
        /usr/include
    Standard Version: c++20
    IntelliSense Mode: linux-gcc-x64
    Other Flags:
        --g++
        --gnu_version=90400
Total Memory Usage: 16 MB

------- Workspace parsing diagnostics -------
Number of files discovered (not excluded): 27212



### Other Extensions

_No response_

### Additional context

I've checked on godbolt that clang can deduce the template arguments for this code correctly. And the project that contains the more complex version of this code compiles with no errors and warnings with GCC.

Beitragsleitfaden

Beitragsleitfaden öffnen

Erste Schritte

  1. Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
  3. Forke das Repository und arbeite in einem Branch.
  4. Öffne einen Pull Request, der die Issue-Nummer nennt.

Rechercherichtung

Reproduzieren Sie die Diagnose in foo.cpp mit der bereitgestellten c_cpp_properties.json unter Verwendung von GNU++20 und /usr/bin/gcc und vergleichen Sie anschließend das Ergebnis von IntelliSense mit dem im Bericht beschriebenen Compilerverhalten. Verfolgen Sie die Verarbeitung der Ableitung von Klassen-Template-Argumenten durch die C/C++-Erweiterung und überprüfen Sie die Vervollständigung, wenn der Code keine Fehler-Markierungen oder Problems-Einträge erzeugt.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
cpp, vscode
Bereich
compilers, devtools
Issue-Typ
Bug
Schwierigkeit
4/5
Geschätzter Aufwand
3-5 Tage
Aktivitätsstatus
Veraltet
Klarheit
Klar beschrieben
Anfängerfreundlichkeit
42/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.