microsoft / microsoft/vscode-cpptools

Linux: Incorrect Intelli-Sense Error: global wchar_t array initialized with wide character string literal

Open
#12,504 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug investigate: repro Language Service Works in VS
Dominant language
TypeScript
Stars
6.2k
Forks
1.7k
Avg merge
14h 46m
Merged PRs (30d)
61

Description

Environment
  • OS and Version: Linux (Ubuntu based 22.04 & 20.04 on WSL)
  • VS Code Version: 1.91.1
  • C/C++ Extension Version: 2.0.0
Bug Summary and Steps to Reproduce

Steps to reproduce:
Create a .c file with a global wchar_t array and initialize it with a wide char string literal (L"..." )
i.e. wchar_t s[] = L"ABC";

Bug Summary:
On Linux the Intelli-Sense Engine seems to identify wide-character string literals as unsigned int arrays while wchar_t is typedef'd by GCC to be signed int, causing a type mismatch which triggers an incorrect error.

The error shown is:
a value of type "unsigned int [4]" cannot be used to initialize an entity of type "wchar_t []" (aka "int []")C/C++(144)

Initializing a const wchar_t * doesn't produce an error.
Initializing in a local scope doesn't produce an error.

Some potentially relevant VSCode settings:

C_Cpp.intelliSenseEngine = deafult
C_Cpp.intelliSenseEngineFallback = disabled

C_Cpp.default.cStandard = C17
(same result for all other available values)

C_Cpp.default.intelliSenseMode = linux-gcc-x64
(or:)
C_Cpp.default.intelliSenseMode = windows-gcc-x64
Configuration and Logs
(some information omitted)


Version: 1.21.3
Current Configuration:
{
    "name": "Linux",
    "cStandard": "c17",
    "cppStandard": "c++17",
    "intelliSenseMode": "linux-gcc-x64",
    "intelliSenseModeIsExplicit": true,
    "cStandardIsExplicit": true,
    "cppStandardIsExplicit": true,
    "mergeConfigurations": false,
}
cpptools version (native): 1.21.3.0

Translation Unit Configurations:

    Process ID: 5302
    Memory Usage: 18 MB
    Compiler Path: /usr/bin/gcc
    Includes:
    System Includes:
        /usr/lib/gcc/x86_64-linux-gnu/9/include
        /usr/local/include
        /usr/include/x86_64-linux-gnu
        /usr/include
    Standard Version: c17
    IntelliSense Mode: linux-gcc-x64
    Other Flags:
        --gcc
        --gnu_version=90400
Total Memory Usage: 18 MB
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 with the reported .c reproducer, the wchar_t global-array declaration, and the Linux GCC IntelliSense configuration. Verify that the diagnostic disappears for the global wide-string initialization while the existing const-pointer and local-scope behavior remains unchanged.

Written by the indexing model from the issue text.

Assessment

Tech stack
c, typescript, vscode
Domain
tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.