| Issue |
179210
|
| Summary |
[clang-tidy] How to solve cppcoreguidelines-pro-type-union-access?
|
| Labels |
clang-tidy
|
| Assignees |
|
| Reporter |
Spixmaster
|
How to read or write with unions while avoiding cppcoreguidelines-pro-type-union-access?
Take the example below.
```cpp
void fun()
{
union v
{
std::int32_t a;
double b;
};
v tmp;
tmp.a = 5; //do not access members of unions; consider using (boost::)variant instead [cppcoreguidelines-pro-type-union-access]
std::cout << tmp.a << std::endl; //do not access members of unions; consider using (boost::)variant instead [cppcoreguidelines-pro-type-union-access]
}
```
`std::variant<>` is not always a solution if the union comes from a C library.
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs