`__Generic` cases cannot contains both `enum` and `size_t`

Open
#14,122 3 comments 0 reactions 1 assignee View on GitHub

@sean-mcmanus is already working on this.

Since Jan 13, 2026.

Assessment

This issue has not been assessed yet.

Description

bug Language Service

bug

__Generic cases cannot contains both enum and size_t within editor

version

1.29.3

description

console output
expected: foo1
expected: foo2
expected: size_t
workaround1: foo1
workaround1: foo2
workaround1: unkown
workaround2: unknown
workaround2: unknown
workaround2: size_t
vscode problems output
[{
	"resource": "/path/to/reproduce.c",
	"owner": "C/C++: IntelliSense",
	"code": "2534",
	"severity": 8,
	"message": "duplicate association type (\"size_t\" (aka \"unsigned int\")) in _Generic selection",
	"source": "C/C++",
	"startLineNumber": 30,
	"startColumn": 3,
	"endLineNumber": 30,
	"endColumn": 11,
	"origin": "extHost2"
},{
	"resource": "/path/to/reproduce.c",
	"owner": "C/C++: IntelliSense",
	"code": "2534",
	"severity": 8,
	"message": "duplicate association type (\"size_t\" (aka \"unsigned int\")) in _Generic selection",
	"source": "C/C++",
	"startLineNumber": 32,
	"startColumn": 3,
	"endLineNumber": 32,
	"endColumn": 11,
	"origin": "extHost2"
},{
	"resource": "/path/to/reproduce.c",
	"owner": "C/C++: IntelliSense",
	"code": "3227",
	"severity": 8,
	"message": "_Generic construct matches multiple types",
	"source": "C/C++",
	"startLineNumber": 34,
	"startColumn": 3,
	"endLineNumber": 34,
	"endColumn": 11,
	"relatedInformation": [
		{
			"startLineNumber": 34,
			"startColumn": 3,
			"endLineNumber": 34,
			"endColumn": 11,
			"message": "the other match is \"foo1\" (aka \"enum <unnamed>\")",
			"resource": "/path/to/reproduce.c"
		}
	],
	"origin": "extHost2"
},{
	"resource": "/path/to/reproduce.c",
	"owner": "C/C++: IntelliSense",
	"code": "3227",
	"severity": 8,
	"message": "_Generic construct matches multiple types",
	"source": "C/C++",
	"startLineNumber": 39,
	"startColumn": 3,
	"endLineNumber": 39,
	"endColumn": 14,
	"relatedInformation": [
		{
			"startLineNumber": 39,
			"startColumn": 3,
			"endLineNumber": 39,
			"endColumn": 14,
			"message": "the other match is \"foo1\" (aka \"enum <unnamed>\")",
			"resource": "/path/to/reproduce.c"
		}
	],
	"origin": "extHost2"
}]

When expected(X) = GENERIC(enum, size_t)(X)

#define expected(X)                                                            \
  printf("%s: %s\n", "expected",                                               \
         _Generic((X), foo1: "foo1", foo2: "foo2", size_t: "size_t"))
  • expected(enum) is OK in terminal, ERR in vscode
  • expected(size_t) is OK in terminal, ERR in vscode

When workaround1(X) = GENERIC(enum, default)(X)

  • workaround1(enum) is OK in terminal, OK in vscode
  • workaround1(size_t) is unknown in terminal, ERR in vscode

When workaround2(X) = GENERIC(size_t, default)(X)

  • workaround2(enum) is unknown in terminal, OK in vscode
  • workaround2(size_t) is OK in terminal, OK in vscode

reproduce

code

/path/to/reproduce.c

#include <stddef.h>
#include <stdio.h>

#define expected(X)                                                            \
  printf("%s: %s\n", "expected",                                               \
         _Generic((X), foo1: "foo1", foo2: "foo2", size_t: "size_t"))

#define workaround1(X)                                                         \
  printf("%s: %s\n", "workaround1",                                            \
         _Generic((X), foo1: "foo1", foo2: "foo2", default: "unkown"))

#define workaround2(X)                                                         \
  printf("%s: %s\n", "workaround2",                                            \
         _Generic((X), size_t: "size_t", default: "unknown"))

typedef enum {
  foo1_default,
} foo1;

typedef enum {
  foo2_default,
} foo2;

int main() {
  foo1 value_foo1 = foo1_default;
  foo2 value_foo2 = foo2_default;
  size_t value_size_t = 0;

  // editor error
  expected(value_foo1);
  // editor error
  expected(value_foo2);
  // editor error
  expected(value_size_t);

  workaround1(value_foo1);
  workaround1(value_foo2);
  // editor error
  workaround1(value_size_t);

  workaround2(value_foo1);
  workaround2(value_foo2);
  workaround2(value_size_t);

  return 0;
}
Dominant language
TypeScript
Stars
6.2k
Forks
1.7k
Avg merge
14h 46m
Merged PRs (30d)
61

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.

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.