Valid octal C23 prefixes 0o and 0O report error 19

Open
#14,872 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
65/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Active
Tech stack
cpp, typescript
Domain
devtools

Research direction

Start by reproducing the report in VS Code with the supplied octal.c example, then trace how the C/C++ extension diagnoses numeric literals in C23 mode. Check that 0o640 and 0O640 no longer produce error 19 while the existing 0640 case still works; the issue names no source files or tests, so locate the relevant parser or diagnostic tests first.

Written by the indexing model from the issue text.

Description

Environment
  • OS and Version: Linux 7.2.14-arch1-1
  • VS Code Version: 1.145.2
  • C/C++ Extension Version: v1.35.6
Bug Summary and Steps to Reproduce

Bug Summary:
The number octal prefixes 0o and 0O wrongly report an error in the editor, even appearing in the 'Problems' tab. Even though this is supported since C23 and it compiles fine.
The error is: extra text after expected end of number C/C++(19)

To reproduce, create an octal.c file in vscode and paste:

#include <stdio.h>

int main(){
	int octal_number0 = 0640; // old school (deprecated in C2y/C29 draft) octal prefix works fine
	int octal_number1 = 0o640; // error 19 reported
	int octal_number2 = 0O640;

	printf("%#x\n", octal_number0); // prints "0x1a0"
	printf("%#x\n", octal_number1); // prints "0x1a0"
	printf("%#x\n", octal_number2); // prints "0x1a0"

	return 0;
}

Compiling with clang -g -Wall -Wextra -std=c23 octal.c -o octal && ./octal works without any error or warning
If you compile with -std=c2y instead, you get a deprecation warning for the 0 prefix, but the other two are still fine

Configuration and Logs
None
Other Extensions

No response

Additional context

No response

Dominant language
TypeScript
Stars
6.2k
Forks
1.7k
Avg merge
1d 17h
Merged PRs (30d)
12

Getting set up

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.

More from microsoft/vscode-cpptools

All issues in microsoft/vscode-cpptools

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.