mirror of
https://github.com/isocpp/CppCoreGuidelines.git
synced 2024-03-22 13:30:58 +08:00
Merge pull request #1179 from jwakely/issue-1177
Fix comment to match code
This commit is contained in:
commit
99b997b6f0
|
@ -3194,6 +3194,8 @@ better
|
||||||
|
|
||||||
**See also**: [Support library](#S-gsl)
|
**See also**: [Support library](#S-gsl)
|
||||||
|
|
||||||
|
**See also**: [Do not pass an array as a single pointer](#Ri-array)
|
||||||
|
|
||||||
##### Enforcement
|
##### Enforcement
|
||||||
|
|
||||||
* (Simple) ((Bounds)) Warn for any arithmetic operation on an expression of pointer type that results in a value of pointer type.
|
* (Simple) ((Bounds)) Warn for any arithmetic operation on an expression of pointer type that results in a value of pointer type.
|
||||||
|
@ -17564,7 +17566,7 @@ Assume that `Apple` and `Pear` are two kinds of `Fruit`s.
|
||||||
void maul(Fruit* p)
|
void maul(Fruit* p)
|
||||||
{
|
{
|
||||||
*p = Pear{}; // put a Pear into *p
|
*p = Pear{}; // put a Pear into *p
|
||||||
p[1] = Pear{}; // put a Pear into p[2]
|
p[1] = Pear{}; // put a Pear into p[1]
|
||||||
}
|
}
|
||||||
|
|
||||||
Apple aa [] = { an_apple, another_apple }; // aa contains Apples (obviously!)
|
Apple aa [] = { an_apple, another_apple }; // aa contains Apples (obviously!)
|
||||||
|
@ -17578,7 +17580,7 @@ If `sizeof(Apple) != sizeof(Pear)` the access to `aa[1]` will not be aligned to
|
||||||
We have a type violation and possibly (probably) a memory corruption.
|
We have a type violation and possibly (probably) a memory corruption.
|
||||||
Never write such code.
|
Never write such code.
|
||||||
|
|
||||||
Note that `maul()` violates the a `T*` points to an individual object [Rule](#???).
|
Note that `maul()` violates the a [`T*` points to an individual object rule](#Rf-ptr).
|
||||||
|
|
||||||
**Alternative**: Use a proper (templatized) container:
|
**Alternative**: Use a proper (templatized) container:
|
||||||
|
|
||||||
|
@ -17594,7 +17596,7 @@ Note that `maul()` violates the a `T*` points to an individual object [Rule](#??
|
||||||
|
|
||||||
Apple& a0 = &va[0]; // a Pear?
|
Apple& a0 = &va[0]; // a Pear?
|
||||||
|
|
||||||
Note that the assignment in `maul2()` violated the no-slicing [Rule](#???).
|
Note that the assignment in `maul2()` violated the [no-slicing rule](#Res-slice).
|
||||||
|
|
||||||
##### Enforcement
|
##### Enforcement
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user