mirror of
https://github.com/isocpp/CppCoreGuidelines.git
synced 2024-03-22 13:30:58 +08:00
commit
3b93c16fbd
|
@ -6868,6 +6868,7 @@ Union rule summary:
|
|||
|
||||
##### Example
|
||||
|
||||
|
||||
???
|
||||
|
||||
##### Enforcement
|
||||
|
@ -6878,6 +6879,7 @@ Union rule summary:
|
|||
|
||||
##### Reason
|
||||
|
||||
|
||||
Naked unions are a source of type errors.
|
||||
|
||||
**Alternative**: Wrap them in a class together with a type field.
|
||||
|
@ -6888,6 +6890,8 @@ Naked unions are a source of type errors.
|
|||
|
||||
???
|
||||
|
||||
|
||||
|
||||
##### Enforcement
|
||||
|
||||
???
|
||||
|
@ -10405,7 +10409,7 @@ Not all data races are as easy to spot as this one.
|
|||
}
|
||||
|
||||
Now, a compiler that does not know that `val` can change will most likely implement that `switch` using a jump table with five entries.
|
||||
Then, a `val` outside the [0..4] range will cause a jump to an address that could be anywhere in the program, and execution would proceed there.
|
||||
Then, a `val` outside the `[0..4]` range will cause a jump to an address that could be anywhere in the program, and execution would proceed there.
|
||||
Really, "all bets are off" if you get a data race.
|
||||
Actually, it can be worse still: by looking at the generated code you may be able to determine where the stray jump will go for a given value;
|
||||
this can be a security risk.
|
||||
|
|
Loading…
Reference in New Issue
Block a user