microsoft / microsoft/vscode-cpptools

Cannot deduce class template arguments

Aperta
#12,299 1 commento 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

bug Language Service Visual Studio
Lingua principale
TypeScript
Stelle
6.2k
Fork
1.7k
Merge medio
14h 46m
PR unite (30g)
61

Descrizione

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.

Guida per i contributori

Apri la guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Direzione di ricerca

Riprodurre la diagnostica in foo.cpp usando il c_cpp_properties.json fornito con GNU++20 e /usr/bin/gcc, quindi confrontare il risultato di IntelliSense con il comportamento del compilatore descritto nel report. Tracciare la gestione della deduzione degli argomenti del template di classe da parte dell’estensione C/C++ e verificare il completamento quando il codice non produce né sottolineature ondulate di errore né voci in Problems.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
cpp, vscode
Ambito
compilers, devtools
Tipo di issue
Bug
Difficoltà
4/5
Tempo stimato
3-5 giorni
Stato di attività
Ferma
Chiarezza
Specificata chiaramente
Idoneità per principianti
42/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.