Skip to content

Commit 930163d

Browse files
authored
Merge pull request #2243 from corob-msft/cr-dd964713
Add /sdl effects to delete operator article
2 parents 4de2a68 + 02ba647 commit 930163d

1 file changed

Lines changed: 8 additions & 8 deletions

File tree

docs/cpp/delete-operator-cpp.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
title: "delete Operator (C++)"
3-
ms.date: "11/04/2016"
3+
ms.date: "08/12/2019"
44
f1_keywords: ["delete_cpp"]
55
helpviewer_keywords: ["delete keyword [C++], syntax", "delete keyword [C++], deallocating objects", "delete keyword [C++]"]
66
ms.assetid: de39c900-3f57-489c-9598-dcb73c4b3930
@@ -11,10 +11,8 @@ Deallocates a block of memory.
1111

1212
## Syntax
1313

14-
```
15-
[::] delete cast-expression
16-
[::] delete [ ] cast-expression
17-
```
14+
> [`::`] `delete` *cast-expression*
15+
> [`::`] `delete []` *cast-expression*
1816
1917
## Remarks
2018

@@ -26,7 +24,7 @@ CDialog* MyDialog = new CDialog;
2624
delete MyDialog;
2725
```
2826

29-
Using **delete** on a pointer to an object not allocated with **new** gives unpredictable results. You can, however, use **delete** on a pointer with the value 0. This provision means that, when **new** returns 0 on failure, deleting the result of a failed **new** operation is harmless. See [The new and delete Operators](../cpp/new-and-delete-operators.md) for more information.
27+
Using **delete** on a pointer to an object not allocated with **new** gives unpredictable results. You can, however, use **delete** on a pointer with the value 0. This provision means that, when **new** returns 0 on failure, deleting the result of a failed **new** operation is harmless. For more information, see [The new and delete Operators](../cpp/new-and-delete-operators.md).
3028

3129
The **new** and **delete** operators can also be used for built-in types, including arrays. If `pointer` refers to an array, place empty brackets before `pointer`:
3230

@@ -42,9 +40,11 @@ When **delete** is used to deallocate memory for a C++ class object, the object'
4240

4341
If the operand to the **delete** operator is a modifiable l-value, its value is undefined after the object is deleted.
4442

43+
If the [/sdl (Enable additional security checks)](/cpp/build/reference/sdl-enable-additional-security-checks) compiler option is specified, the operand to the **delete** operator is set to an invalid value after the object is deleted.
44+
4545
## Using delete
4646

47-
There are two syntactic variants for the [delete operator](../cpp/delete-operator-cpp.md): one for single objects and the other for arrays of objects. The following code fragment shows how these differ:
47+
There are two syntactic variants for the [delete operator](../cpp/delete-operator-cpp.md): one for single objects and the other for arrays of objects. The following code fragment shows how they differ:
4848

4949
```cpp
5050
// expre_Using_delete.cpp
@@ -70,7 +70,7 @@ int main()
7070
}
7171
```
7272

73-
The following two cases produce undefined results: using the array form of delete (delete [ ]) on an object and using the nonarray form of delete on an array.
73+
The following two cases produce undefined results: using the array form of delete (`delete []`) on an object, and using the nonarray form of delete on an array.
7474

7575
## Example
7676

0 commit comments

Comments
 (0)