Skip to content

Instantly share code, notes, and snippets.

@nic-hartley
Created November 2, 2017 03:22
Show Gist options
  • Save nic-hartley/bd068ea703eb7e06b4c2d6b6c703abf4 to your computer and use it in GitHub Desktop.
Save nic-hartley/bd068ea703eb7e06b4c2d6b6c703abf4 to your computer and use it in GitHub Desktop.
/*
This gist demonstrates an issue with Clang-Tidy, I think.
Basically, you shouldn't be required to initialize all members of a
union, for obvious reasons, but Clang-Tidy doesn't care that the
"missing" members are part of a union, and tries to get them to be
initialized anyway.
*/
struct Type {
union {
int _a;
float _b;
};
double _c;
// Warning here that _b isn't initialized
Type(int a, double c) : _a(a), _c(c) {}
// Warning here that _a isn't initialized
Type(float b, double c) : _b(b), _c(c) {}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment