microsoft / microsoft/vscode-cpptools

gcc emulation: Intellisense produces error where GCC does not in the case of statement expressions

Open
#13,685 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug parser Visual Studio
Dominant language
TypeScript
Stars
6.2k
Forks
1.7k
Avg merge
14h 46m
Merged PRs (30d)
61

Description

Environment
  • OS and Version: macOS Sequoia 15.5
  • VS Code Version: 1.100.3
  • C/C++ Extension Version: 1.25.3
  • If using SSH remote, specify OS of remote machine: Ubuntu 20.04.6 LTS
Bug Summary and Steps to Reproduce

Bug Summary:
When given a minimal program which initializes a static instance of a class inside a GCC statement expression, Intellisense produces an error squiggle while the program compiles cleanly in GCC. This is using GCC 10.5.0 on Ubuntu 20.04 (x86_64).

Steps to reproduce:
Create a CMake project with a single C++ file with this content:

class ValueContainer
{
public:
    ValueContainer(int value) : value_(value) {}

private:
    int value_;
};

#define DO_SOMETHING(value) (({ \
    static ValueContainer foo{value}; \
    &foo; \
}))

int main()
{
    DO_SOMETHING(1);
    return 0;
}

Enable the VSCode C++ and CMake Tools extensions on the project.

An error squiggle is seen at line 17 with the message "a dynamically-initialized local static variable is not allowed inside of a statement expressionC/C++(1232)".

Image

The program compiles cleanly with no warnings with GCC either invoked from the command line or via the CMake Tools extension.

Expected behavior:
VS Code produces no error squiggles

Configuration and Logs
C++ configured automatically through CMake Tools, the default configuration. Here is a dump from the debug logs:

Custom browse configuration received: {
  "browsePath": [
    "/home/skearney/devenv-wip/vscode-cpp-test"
  ],
  "compilerPath": "/usr/bin/X11/g++",
  "compilerArgs": [],
  "compilerFragments": [
    "-g"
  ]
}
Other Extensions

No response

Additional context

No response

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the minimal CMake project and comparing the IntelliSense squiggle with GCC's clean result. Trace how IntelliSense handles GCC statement expressions containing a dynamically initialized local static, then verify that the diagnostic disappears while valid diagnostics remain.

Written by the indexing model from the issue text.

Assessment

Tech stack
cmake, cpp
Domain
compilers, developer-experience
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.