Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Intellisense no longer resolves overloaded range algorithm with range as first argument? #10252

Closed
jducaud opened this issue Dec 8, 2022 · 12 comments
Labels
bug fixed Check the Milestone for the release in which the fix is or will be available. Language Service regression A bug that didn't exist in a previous release verified Bug has been reproduced Visual Studio Inherited from Visual Studio
Milestone

Comments

@jducaud
Copy link

jducaud commented Dec 8, 2022

Environment

  • Windows 11 Pro 22H2 22621.900
  • VS Code 1.74.0
  • C/C++ Extension 1.13.6
  • WSL:Ubuntu-22.04 with gcc/g++ 12.1 (-std=c++23)
  • Single project workspace

Today (2022-12-07 - because yesterday - 2022-12-07 - everything was fine), Intellisense reports multiple errors in the VS Code problems panel. All those errors concern the C++ ranges library:

  • the overloaded range algorithms with iterator/sentinel parameters are resolved
  • the overloaded range algorithms with range parameter are no longer resolved
  • the "pipe composition style" of the range adaptors is no longer supported

Only intellisense is affected. The compilation/run task (in WSL and Compiler Explorer) is performed without errors.

Bug Summary and Steps to Reproduce

Bug Summary: Intellisense yields false errors regarding some ranges library features:

  • the overloaded range algorithms with range parameter are not resolved
  • the "pipe composition style" of the range adaptors is not supported

Steps to reproduce:
Try:

std::string s{"hello WORLD!"};
std::ranges::transform(s, s.begin(),
                       [](unsigned char c) -> unsigned char
                       { return std::toupper(c); });

And

for (int i : std::views::iota(1) | std::views::take(7))
    std::cout << i << ' ';
std::cout << std::endl;

Expected behavior

Intellisense should not yield those false errors. It compiles and runs fine with gcc 12.1 in WSL/Ubuntu-22.04 and it compiles and runs fine with x86-64 gcc 12.1 in Compiler Explorer.

Yesterday everything was working fine and I did not modify any settings in VS Code since.

Code sample and Logs

// Code sample ---------------------------------------------
#include <algorithm>
#include <iostream>
#include <ranges>
#include <string>

int main()
{
    std::string s{"hello WORLD!"};
    // the "iterator/sentinel parameters" overload of "__transform_fn" is still resolved
    std::ranges::transform(s.begin(), s.end(), s.begin(),
                           [](unsigned char c) -> unsigned char
                           { return std::tolower(c); });
    // the "range parameter" overload of "__transform_fn" is not resolved anymore
    std::ranges::transform(s, s.begin(),
                           [](unsigned char c) -> unsigned char
                           { return std::toupper(c); });
    std::cout << s << std::endl;

    // the "pipe composition style" is no longer supported
    for (int i : std::views::iota(1) | std::views::take(7))
        std::cout << i << ' ';
    std::cout << std::endl;
    // the "functional composition style" fails because the "range parameter" overload
    // of "_Take" is not resolved anymore
    for (int i : std::views::take(std::views::iota(1), 7))
        std::cout << i << ' ';
    std::cout << std::endl;
}

// c_cpp_properties.json ----------------------------------
{
    "configurations": [
        {
            "name": "Linux",
            "includePath": [
                "${workspaceFolder}/**"
            ],
            "defines": [],
            "compilerPath": "/usr/bin/gcc",
            "cStandard": "gnu17",
            "cppStandard": "gnu++23",
            "intelliSenseMode": "linux-gcc-x64",
            "configurationProvider": "ms-vscode.cmake-tools"
        }
    ],
    "version": 4
}

Screenshots

2022-12-08 - 16-06-41 - Code
CTRL+F5 in VS Code yields:

 *  Executing task in folder test: make 

g++ -std=gnu++23 -Wall -ggdb -Iinclude src/main.cpp -o bin/main 
 *  Terminal will be reused by tasks, press any key to close it.

The output is:

HELLO WORLD!
1 2 3 4 5 6 7 
1 2 3 4 5 6 7 
[1] + Done                       "/usr/bin/gdb" --interpreter=mi --tty=${DbgTerm} 0<"/tmp/Microsoft-MIEngine-In-5xrkqmu3.55q" 1>"/tmp/Microsoft-MIEngine-Out-mh53pvru.2qs"

Additional context

No response

@jducaud
Copy link
Author

jducaud commented Dec 8, 2022

Note: in the screenshot I simplified the second transform operation by removing "std::toupper", just to see if that would change the outcome. It did not change anything.

@jducaud
Copy link
Author

jducaud commented Dec 8, 2022

I have just installed the "Microsoft Build Tools for Visual Studio 2022" and used them ("cl.exe" with the "/std:c++latest" option to be precise) inside VS Code in Windows (hence no WSL2 here).

VS Code C++ linter correctly handles the ranges library features mentioned above with msvc (cl.exe).

To sum up:

  • g++ 12.1 in WSL2 correctly compiles and runs the sample code
  • in WSL2-Ubuntu-22.04, VS Code C++ linter displays false errors in the problems panel
  • cl.exe 19.34.31935 in Windows correctly compiles and runs the sample code
  • in Windows, VS Code C++ linter does not display false errors

This problem seems to be related to the "remote WSL2 thing"...

@jducaud
Copy link
Author

jducaud commented Dec 8, 2022

I rolled back VS Code from 1.74.0 to 1.71.2... The issue was still there. Then I rolled back the C/C++ extension from 1.13.6 to 1.12.4 and found out there was no issue anymore.

Conclusion: The C/C++ extension 1.13.6 brings an issue (not present in the 1.12.4 version) with the WSL2 remote environment.

So I will stay with the 1.12.4 version, until this linter bug is fixed.

@sean-mcmanus sean-mcmanus added bug Language Service regression A bug that didn't exist in a previous release labels Dec 9, 2022
@sean-mcmanus sean-mcmanus added this to the 1.14 milestone Dec 9, 2022
@sean-mcmanus sean-mcmanus added the investigate: repro This issue's repro steps needs to be investigated/confirmed label Dec 9, 2022
@Gryfenfer97
Copy link

I have the same error with the following code

#include <vector>
#include <algorithm>

int main(){
    std::vector<int> v = {1, 2, 3, 4};
    std::ranges::find(v.begin(), v.end(), 1); // No error
    std::ranges::find(v, 1); // "no instance of overloaded function ..."
}

the error:

no instance of overloaded function "std::ranges::__find_fn::operator()" matches the argument list C/C++(304)
main.cpp(7, 5): argument types are: (std::vector<int, std::allocator<int>>, int)
main.cpp(7, 5): object type is: const std::ranges::__find_fn

And my settings.json

{
    "C_Cpp.default.configurationProvider": "ms-vscode.cmake-tools",
    "C_Cpp.default.cppStandard": "c++20",
    "C_Cpp.default.cStandard": "c17",
    "C_Cpp.default.intelliSenseMode": "linux-gcc-x64"
}

And the same thing, everything compile fine but I get this intellisense error message.

Environment

  • ArchLinux
  • VS Code 1.74.0
  • C/C++ Extension 1.13.7
  • g++ 12.2.0 (c++20)

@mly32
Copy link

mly32 commented Dec 11, 2022

Bumping for visibility on this.

I was able to resolve it for now with @jducaud's solution.

@sean-mcmanus sean-mcmanus self-assigned this Dec 15, 2022
@sean-mcmanus sean-mcmanus added the verified Bug has been reproduced label Dec 15, 2022
@sean-mcmanus sean-mcmanus added the Visual Studio Inherited from Visual Studio label Dec 16, 2022
@sean-mcmanus sean-mcmanus modified the milestones: 1.14, Tracking Dec 16, 2022
@sean-mcmanus sean-mcmanus removed the investigate: repro This issue's repro steps needs to be investigated/confirmed label Dec 16, 2022
@sean-mcmanus
Copy link
Contributor

sean-mcmanus commented Dec 16, 2022

I've reported an internal bug on VS: 1706892 and let them know we consider this a high priority.

@sean-mcmanus sean-mcmanus removed their assignment Dec 16, 2022
@jducaud
Copy link
Author

jducaud commented Jan 27, 2023

Hello Sean (@sean-mcmanus ), have you any good news about this VS Code internal bug? Is there a way to follow its processing? I tried unsuccessfully to find a VS Code repository issue #1706892 - It seems that the issue numbers are more around 172000 on this repository nowadays, but maybe, as it's an "internal" bug, it has not public visibility... or it is simply a typo in your message? (an unwanted extra-digit) Regards, Jerome.

@sean-mcmanus
Copy link
Contributor

@jducaud The bug is in the internal VS bug database so it's not publicly visible -- the bug is active/approved...no other updates yet. I've added a message to the issue.

@jducaud
Copy link
Author

jducaud commented Feb 7, 2023

Thank you @sean-mcmanus !

@Jesseeee
Copy link

Same issue, keep getting errors on valid std::ranges calls, doesn't matter which function of the ranges library I use

@sean-mcmanus sean-mcmanus modified the milestones: Tracking, 1.15.0 Mar 16, 2023
@sean-mcmanus sean-mcmanus added the fixed Check the Milestone for the release in which the fix is or will be available. label Mar 16, 2023
@sean-mcmanus
Copy link
Contributor

The fix is available with 1.15.0 (pre-release): https://github.com/microsoft/vscode-cpptools/releases/tag/v1.15.0

If you're still hitting an incorrect IntelliSense error with ranges, you're probably hitting a different root cause bug, such as #9953 and #8039, or let us know the details in a new issue if you believe it's a different root cause.

@jducaud
Copy link
Author

jducaud commented Mar 16, 2023

Thank you @sean-mcmanus!
I have just tested this pre-release 1.15.0 and the issue is gone.

@jducaud jducaud closed this as completed Mar 16, 2023
@github-actions github-actions bot locked and limited conversation to collaborators May 1, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug fixed Check the Milestone for the release in which the fix is or will be available. Language Service regression A bug that didn't exist in a previous release verified Bug has been reproduced Visual Studio Inherited from Visual Studio
Projects
None yet
Development

No branches or pull requests

5 participants