Skip to content

Commit 5d3c869

Browse files
author
Colin Robertson
authored
Merge pull request MicrosoftDocs#2433 from MicrosoftDocs/master637347533073753485
Repo sync for protected CLA branch
2 parents 95acdad + 093f49b commit 5d3c869

File tree

9 files changed

+115
-10
lines changed

9 files changed

+115
-10
lines changed

docs/code-quality/c26462.md

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,26 @@ ms.date: 03/22/2018
44
ms.topic: reference
55
f1_keywords: ["C26462"]
66
helpviewer_keywords: ["C26462"]
7+
description: CppCoreCheck rule that enforces C++ Core Guidelines Con.4
78
---
89
# C26462 USE_CONST_POINTER_FOR_VARIABLE
910

10-
The value pointed to by '%variable%' is assigned only once, mark it as a pointer to `const`. See [C++ Core Guidelines con.4](https://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md#con4-use-const-to-define-objects-with-values-that-do-not-change-after-construction).
11+
The value pointed to by '%variable%' is assigned only once, mark it as a pointer to `const` (con.4).
12+
13+
Pointers to variables whose values remain unchanged should be marked as const.
14+
15+
## See also
16+
[C++ Core Guidelines con.4](https://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md#con4-use-const-to-define-objects-with-values-that-do-not-change-after-construction).
17+
18+
## Example
19+
```cpp
20+
void useVal(int val);
21+
22+
void function1(int* ptr)
23+
{
24+
int* p = ptr; // C26462, the value pointed to by p is unmodified
25+
ptr = nullptr;
26+
27+
useVal(*p);
28+
}
29+
```

docs/code-quality/c26463.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,14 @@ ms.date: 03/22/2018
44
ms.topic: reference
55
f1_keywords: ["C26463"]
66
helpviewer_keywords: ["C26463"]
7+
description: CppCoreCheck placeholder warning for future con.4 enforcement
78
---
89
# C26463 USE_CONST_FOR_ELEMENTS
910

10-
The elements of array '%array%' are assigned only once, mark elements `const`. See [C++ Core Guidelines con.4](https://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md#con4-use-const-to-define-objects-with-values-that-do-not-change-after-construction).
11+
The elements of array '%array%' are assigned only once, mark elements `const` (con.4)
12+
13+
## See also
14+
[C++ Core Guidelines con.4](https://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md#con4-use-const-to-define-objects-with-values-that-do-not-change-after-construction).
15+
16+
## Remark
17+
- This rule is currently not implemented in CppCoreCheck.

docs/code-quality/c26464.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,14 @@ ms.date: 03/22/2018
44
ms.topic: reference
55
f1_keywords: ["C26464"]
66
helpviewer_keywords: ["C26464"]
7+
description: CppCoreCheck placeholder warning for future con.4 enforcement
78
---
89
# C26464 USE_CONST_POINTER_FOR_ELEMENTS
910

10-
The values pointed to by elements of array '%array%' are assigned only once, mark elements as pointer to `const`. See [C++ Core Guidelines con.4](https://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md#con4-use-const-to-define-objects-with-values-that-do-not-change-after-construction).
11+
The values pointed to by elements of array '%array%' are assigned only once, mark elements as pointer to `const` (con.4).
12+
13+
## See also
14+
[C++ Core Guidelines con.4](https://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md#con4-use-const-to-define-objects-with-values-that-do-not-change-after-construction).
15+
16+
## Remarks
17+
- This rule is currently not implemented in CppCoreCheck.

docs/code-quality/c26483.md

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,24 @@ ms.date: 03/22/2018
44
ms.topic: reference
55
f1_keywords: ["C26483"]
66
helpviewer_keywords: ["C26483"]
7+
description: CppCoreCheck rule that enforces C++ Core Guidelines Bounds.2
78
---
89
# C26483 STATIC_INDEX_OUT_OF_RANGE
910

10-
Value %value% is outside the bounds (0, %bound%) of variable '%variable%'. Only index into arrays using constant expressions that are within bounds of the array. See [C++ Core Guidelines Bounds.2](https://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md#SS-bounds)
11+
Value %value% is outside the bounds (0, %bound%) of variable '%variable%'. Only index into arrays using constant expressions that are within bounds of the array (bounds.2).
12+
13+
## See also
14+
[C++ Core Guidelines Bounds.2](https://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md#SS-bounds)
15+
16+
## Example
17+
```cpp
18+
void function()
19+
{
20+
std::array<int, 3> arr1 { 1, 2, 3 };
21+
arr1[3] = 4; // C26483, 3 is outside the bounds of the array
22+
23+
int arr2[] { 1, 2, 3 };
24+
arr2[3] = 4; // C26483, 3 is outside the bounds of the array
25+
}
26+
27+
```

docs/code-quality/c26495.md

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,29 @@ ms.date: 03/22/2018
44
ms.topic: reference
55
f1_keywords: ["C26495"]
66
helpviewer_keywords: ["C26495"]
7+
description: CppCoreCheck rule that enforces C++ Core Guidelines Type.6
78
---
89
# C26495 MEMBER_UNINIT
910

10-
Variable '%variable%' is uninitialized. Always initialize a member variable. See [C++ Core Guidelines Type.6](https://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md#SS-type).
11+
Variable '%variable%' is uninitialized. Always initialize a member variable (type.6).
12+
13+
## See also
14+
C++ Core Guidelines [Type.6](https://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md#SS-type) and [C.48](https://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md#c48-prefer-in-class-initializers-to-member-initializers-in-constructors-for-constant-initializers)
15+
16+
17+
## Example
18+
```cpp
19+
struct MyStruct
20+
{
21+
int value;
22+
MyStruct() {}; // C26495, MyStruct::value is uninitialized
23+
};
24+
```
25+
To fix the warning, add in-class initializers to all of the member variables. See the above linked C++ Core Guidelines pages for additional information.
26+
```cpp
27+
struct MyStruct
28+
{
29+
int value{};
30+
MyStruct() {}; // no warning, MyStruct::value is set via default member initialization
31+
};
32+
```

docs/code-quality/c26496.md

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,26 @@ ms.date: 03/22/2018
44
ms.topic: reference
55
f1_keywords: ["C26496"]
66
helpviewer_keywords: ["C26496"]
7+
description: CppCoreCheck rule that enforces C++ Core Guidelines Con.4
78
---
89
# C26496 USE_CONST_FOR_VARIABLE
910

10-
> The variable '*variable*' is assigned only once, mark it as `const`. See [C++ Core Guidelines con.4](https://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md#con4-use-const-to-define-objects-with-values-that-do-not-change-after-construction).
11+
> The variable '*variable*' is assigned only once, mark it as `const`.
12+
13+
## See also
14+
[C++ Core Guidelines con.4](https://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md#con4-use-const-to-define-objects-with-values-that-do-not-change-after-construction).
15+
16+
## Example
17+
```cpp
18+
int GetTheNumber();
19+
int GiveMeTheNumber(int);
20+
21+
void function1()
22+
{
23+
int theNumber = GetTheNumber(); // C26496, 'theNumber' is never assigned to again, so it can be marked as const
24+
std::cout << theNumber << '\n';
25+
26+
GiveMeTheNumber(theNumber);
27+
// ...
28+
}
29+
```

docs/code-quality/c26497.md

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,21 @@ ms.date: 03/22/2018
44
ms.topic: reference
55
f1_keywords: ["C26497"]
66
helpviewer_keywords: ["C26497"]
7+
description: CppCoreCheck rule that enforces C++ Core Guidelines F.4
78
---
89
# C26497 USE_CONSTEXPR_FOR_FUNCTION
910

10-
This function %function% could be marked `constexpr` if compile-time evaluation is desired. See [C++ Core Guidelines F.4](https://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md#Rf-constexpr).
11+
This function %function% could be marked `constexpr` if compile-time evaluation is desired (f.4).
12+
13+
## See also
14+
[C++ Core Guidelines F.4](https://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md#Rf-constexpr).
15+
16+
## Example
17+
```cpp
18+
const int GetTheAnswer(int x) noexcept { return 42 + x; } // Could be marked constexpr
19+
20+
void function1() noexcept
21+
{
22+
const int theAnswer = GetTheAnswer(0);
23+
}
24+
```

docs/parallel/amp/cpp-amp-cpp-accelerated-massive-parallelism.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,6 @@ C++ AMP (C++ Accelerated Massive Parallelism) accelerates the execution of your
2929

3030
## Other Resources
3131

32-
[Parallel Programming in Native Code Blog](https://go.microsoft.com/fwlink/p/?linkid=238472)<br/>
33-
[C++ AMP sample projects for download](https://go.microsoft.com/fwlink/p/?linkid=248508)<br/>
32+
[Parallel Programming in Native Code Blog](/archive/blogs/nativeconcurrency/)<br/>
33+
[C++ AMP sample projects for download](/archive/blogs/nativeconcurrency/c-amp-sample-projects-for-download)<br/>
3434
[Analyzing C++ AMP Code with the Concurrency Visualizer](/archive/blogs/nativeconcurrency/analyzing-c-amp-code-with-the-concurrency-visualizer)

docs/parallel/amp/cpp-amp-overview.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -497,4 +497,4 @@ Modulus and division of unsigned integers have significantly better performance
497497
[C++ AMP (C++ Accelerated Massive Parallelism)](../../parallel/amp/cpp-amp-cpp-accelerated-massive-parallelism.md)<br/>
498498
[Lambda Expression Syntax](../../cpp/lambda-expression-syntax.md)<br/>
499499
[Reference (C++ AMP)](../../parallel/amp/reference/reference-cpp-amp.md)<br/>
500-
[Parallel Programming in Native Code Blog](https://go.microsoft.com/fwlink/p/?linkid=238472)
500+
[Parallel Programming in Native Code Blog](/archive/blogs/nativeconcurrency/)

0 commit comments

Comments
 (0)