Skip to content

[clang-tidy] bugprone-tagged-union-member-count false warning when using enum & pthread_mutex_t #134840

@abdelmaged

Description

@abdelmaged

Source C file:

#include <pthread.h>

typedef enum {
  MYENUM_ONE,
  MYENUM_TWO,
} myEnumT;

typedef struct {
  pthread_mutex_t mtx;       
  myEnumT         my_enum;
} myTypeT;

Using clang-tidy bugprone-tagged-union-member-count:

<source>:8:9: warning: tagged union has more data members (3) than tags (2)! [bugprone-tagged-union-member-count]
    8 | typedef struct {
      |         ^
1 warning generated.

This is incorrect warning.

clang-tidy vesion: 20.1.1

Issue also reproducible in this link:
https://godbolt.org/z/o3fb9bbrb

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions