microsoft / microsoft/vscode-cpptools
Cannot deduce class template arguments
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 6.2k
- Forks
- 1.7k
- Avg merge
- 14h 46m
- Merged PRs (30d)
- 61
Description
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:
- Put the following code into a file foo.cpp.
- 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.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the diagnostic in foo.cpp using the provided c_cpp_properties.json with GNU++20 and /usr/bin/gcc, then compare IntelliSense's result with the compiler behavior described in the report. Trace the C/C++ extension's handling of class template argument deduction and verify completion when the code produces no error squiggles or Problems entries.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp, vscode
- Domain
- compilers, devtools
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 42/100