vscode-cpptools icon indicating copy to clipboard operation
vscode-cpptools copied to clipboard

typeof incorrectly removes qualifiers in some situations (with C clang/gcc modes)

Open Halalaluyafail3 opened this issue 6 months ago • 3 comments

Environment

  • OS and Version: Windows 10
  • VS Code Version: 1.100.2
  • C/C++ Extension Version: 1.25.3

Bug Summary and Steps to Reproduce

Bug Summary:

Steps to reproduce: Use typeof with a qualified or atomic lvalue obtained from dereferencing a pointer to a qualified or atomic type, for example:

typedef typeof(*(const int*)0)x;

When hovering over this definition, it reports x as being the type int.

Expected behavior: The reported type of x should be const int.

Configuration and Logs

{
	"configurations": [
		{
			"name": "Win32",
			"includePath": [
				"${workspaceFolder}/**"
			],
			"defines": [
				"_DEBUG",
				"UNICODE",
				"_UNICODE"
			],
			"cStandard": "c23",
			"cppStandard": "c++23",
			"intelliSenseMode": "linux-gcc-x64",
			"compilerPath": "C:/cygwin64/bin/gcc.exe"
		}
	],
	"version": 4
}

Other Extensions

No response

Additional context

Image

This issue does not occur when using an lvalue derived from a name instead of dereferencing a pointer, e.g.:

Image

Halalaluyafail3 avatar May 16 '25 23:05 Halalaluyafail3

@Halalaluyafail3 It works for me with cygwin with c++23. Can you run C/C++: Log Diagnostics to see how IntelliSense is being configured? What gnu_version is reported?

Image

sean-mcmanus avatar May 19 '25 20:05 sean-mcmanus

@sean-mcmanus I guess I didn't make it clear enough, but this is specifically about C. The issue goes away if the file is C++. The compiler path is the same as yours but with gcc instead of g++, and searching for gnu_version I see --gnu_version=150001.

Halalaluyafail3 avatar May 19 '25 22:05 Halalaluyafail3

@Halalaluyafail3 I've reported a bug on our shared VS parser at https://developercommunity.visualstudio.com/t/C-IntelliSense-with-clanggcc-mode-incor/10906841 . The issue repros with C with clang/gcc modes (not with msvc mode or C++).

sean-mcmanus avatar May 19 '25 23:05 sean-mcmanus