Skip to content

erroneous "set but not used" warnings with reference variables #14801

Description

@marralesfios

Environment

  • OS and Version: Arch Linux (linux 7.2.6.arch2-1)
  • VS Code Version: 1.139.0 commit 2242ebbb54efeeb0129e08e919e7e8d43033cd83
  • C/C++ Extension Version: pre-release 1.35.2
  • If using SSH remote, specify OS of remote machine: N/A

Bug Summary and Steps to Reproduce

Bug Summary:

In the following code:

void modify(int& x){
    x = 3;
}

x is being erroneously marked as set-but-unused, even though the assignment can be useful.

Image

Steps to reproduce:

  1. Create a blank folder and a .cpp file with the content shown above in it
  2. Open the file
  3. See error

Expected behavior:
The variable is recognized as used and not dimmed, and there is no warning message on hover.

Configuration and Logs

c_cpp_properties.json: (none)

Log Diagnostics output

Language Server logging

Other Extensions

No response

Additional context

No response

No activity

Activity on this issue will appear here.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

Language ServicebugfixedCheck the Milestone for the release in which the fix is or will be available.

Type

Projects

  • Status
    Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions