microsoft / microsoft/vscode-cpptools

incorrectly formed universal character name using \u{...}

Open
#12,341 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

Environment
  • OS and Version: Fedora 40
  • VS Code Version: 1.89.1
  • C/C++ Extension Version: 1.20.5
Bug Summary and Steps to Reproduce

Bug Summary:

When writing std::string utf8_str = "\u{1F604}"; into a cpp file, the language server says incorrectly formed universal character name C/C++(965) however compilation and execution works fine.

Steps to reproduce:

  1. Create a cpp file an copy/paste this code:
#include <iostream>

int main() {
  std::string utf8_str = "\u{1F604}";
  std::cout << "UTF-8 string: " << utf8_str << std::endl;

  return 0;
}

  1. Compile it, I'm using g++ compiler

Expected behavior:
No error

image

Configuration and Logs
{
  "configurations": [
    {
      "name": "Linux",
      "includePath": ["${workspaceFolder}/**"],
      "defines": [],
      "compilerPath": "/usr/bin/gcc",
      "cStandard": "c17",
      "cppStandard": "gnu++17",
      "intelliSenseMode": "linux-gcc-x64"
    }
  ],
  "version": 4
}
Other Extensions

No response

Additional context

https://en.cppreference.com/w/cpp/language/escape

Note \u{n...} (since C++23) -> code point U+n... (arbitrary number of hexadecimal digits)

My compiler is using C++17 and works, also tried to change cppStandard to gnu++23 but still persist the error

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

Use the provided C++ snippet as the reproduction case, first compiling it with g++ and checking the language-server diagnostic under the supplied c_cpp_properties configuration. Compare the diagnostic with cppStandard set to gnu++17 and gnu++23; done means the valid universal character name no longer produces an incorrect error while the existing compilation behavior remains intact.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.