IntelliSense reports an error on a valid deduction guide (error: the return type must directly designate a specialization of the associated class template) · Issue #14824 · microsoft/vscode-cpptools · GitHub
You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
IntelliSense reports an error on a valid deduction guide (error: the return type must directly designate a specialization of the associated class template) #14824
Compilers that accept the code: Apple clang 21.0.0 (clang-2100.3.34.2), GCC 16.2.0 (-std=c++23 -Wall -Wextra -pedantic)
Bug Summary and Steps to Reproduce
Bug Summary:
IntelliSense reports an error on a valid deduction guide whose return type is an explicit specialization of the class template. Clang and GCC compile and run the code without warnings.
Steps to reproduce:
Set the "cppStandard": "gnu++20".
#include<cstddef>
#include<span>using std::size_t;
template< size_t i = std::dynamic_extent, size_t s = std::dynamic_extent >
structslice
{
staticconstexprsize_t index = i, size = s;
};
template<>
structslice< std::dynamic_extent, std::dynamic_extent >
{
size_t index = 0, size = 0;
constexprslice() noexcept = default;
constexprslice( size_t i, size_t s ) noexcept : index( i ), size( s ) {}
};
slice() -> slice<>;
slice( size_t, size_t ) -> slice<>; // error: "the return type must directly designate a specialization of the associated class template"template< size_t i, size_t s >
constexpr slice< i, s > const_slice;
auto s0 = slice{}; // OKauto s1 = slice{ 1, 2 }; // errorauto s2 = slice< 3, 4 >{}; // OKauto s3 = const_slice< 5, 6 >; // OK
slice s5 = { 2, 4 }; // error
slice s6; // OKsize_t n = 1;
auto s7 = slice{ n, 3 }; // errorintmain() {}
Update: switching to 1.35.3 only partly fixed the problem. Now the error occurs at these lines:
slice() -> slice<>; // redeclaration of deduction guide "()->slice<18446744073709551615UL, 18446744073709551615UL>" (previous declaration at line 30)slice( size_t, size_t ) -> slice<>; // rredeclaration of deduction guide "(size_t, size_t)->slice<18446744073709551615UL, 18446744073709551615UL>" (previous declaration at line 32)
Unfortunately version 1.35.5 still reports bogus errors:
redeclaration of deduction guide "()->slice<0UL, 18446744073709551615UL>" (previous declaration at line 39)
redeclaration of deduction guide "(size_t)->slice<0UL, 18446744073709551615UL>" (previous declaration at line 41)
redeclaration of deduction guide "(size_t, size_t)->slice<0UL, 18446744073709551615UL>" (previous declaration at line 43)
Sample code:
#include<cstddef>
#include<span>template< std::size_t i = 0, std::size_t s = std::dynamic_extent >
structslice
{
staticconstexpr std::size_t index = i, size = s;
};
// Full specialisation for the default arguments, with run-time memberstemplate<>
structslice< 0, std::dynamic_extent >
{
std::size_t index = 0, size = 0;
constexprslice() noexcept = default;
constexprslice( std::size_t i, std::size_t s = 1 ) noexcept : index( i ), size( s ) {}
};
// Each guide is declared exactly onceslice() -> slice<>; // error: redeclaration of deduction guide ...slice( std::size_t ) -> slice<>; // error: redeclaration of deduction guide ...slice( std::size_t, std::size_t ) -> slice<>; // error: redeclaration of deduction guide ...intmain()
{
constexpr slice a;
constexpr slice b( 2 );
constexpr slice c( 2, 3 );
constexpr slice< 1, 2 > d;
static_assert( std::is_same_v< decltype( a ), const slice<> > );
static_assert( c.index == 2and c.size == 3and d.size == 2and b.size == 1 );
}
Hi Dominik Deák (@DominikDeak) . We're not easily able to repro an issue with the code provided, with 1.35.5, including on macOS with Apple Clang 21. Could you fully reload VS Code (to confirm it's definitely not still using the prior version) and provide log output from a repro? Maybe both C/C++: Log Diagnostics output, and any relevant output from the C/C++ output channel with "C_Cpp.loggingLevel": "Debug"? That might provide us with some clues.
Apologies, my mistake. The plugin was updated, but VSCode didn't reload. After reloading the app, I can confirm the issue has been resolved. Thanks for looking into this.
Activity
sean-mcmanus commentedon Oct 28, 2026
Dominik Deák (@DominikDeak) Fixed with https://github.com/microsoft/vscode-cpptools/releases/tag/v1.35.5
DominikDeak commentedon Oct 28, 2026
Sean McManus (@sean-mcmanus) thanks for the update.
Unfortunately version 1.35.5 still reports bogus errors:
Sample code:
Colengms commentedon Oct 29, 2026
Hi Dominik Deák (@DominikDeak) . We're not easily able to repro an issue with the code provided, with 1.35.5, including on macOS with Apple Clang 21. Could you fully reload VS Code (to confirm it's definitely not still using the prior version) and provide log output from a repro? Maybe both
C/C++: Log Diagnosticsoutput, and any relevant output from the C/C++ output channel with"C_Cpp.loggingLevel": "Debug"? That might provide us with some clues.DominikDeak commentedon Oct 29, 2026
Apologies, my mistake. The plugin was updated, but VSCode didn't reload. After reloading the app, I can confirm the issue has been resolved. Thanks for looking into this.