---
title: C6283
ms.date: 11/04/2016
ms.topic: reference
f1_keywords: ["C6283"]
helpviewer_keywords: ["C6283"]
ms.assetid: 7760d32e-6d71-4c81-a6d2-719c9c76c2bb
---
# C6283

> warning C6283: \<variable> is allocated with array new [], but deleted with scalar delete

This warning appears only in C++ code and indicates that the calling function has inconsistently allocated memory with the array `new []` operator, but freed it with the scalar **`delete`** operator. This defect might cause leaks, memory corruptions, and, in situations where operators have been overridden, crashes. If memory is allocated with array `new []`, it should typically be freed with array `delete[]`.

## Example

The following code generates this warning:

```cpp
void f( )
{
  char *str = new char[50];
  // code ...
  delete str;
}
```

To correct this warning, use the following code:

```cpp
void f( )
{
  char *str = new char[50];
  // code ...
  delete[] str;
}
```

Warning C6283 only applies to arrays of primitive types such as, integers or characters. If elements of the array are objects of class type then warning [C6278](../code-quality/c6278.md) is issued.

The use of new and delete have many pitfalls in terms of memory leaks and exceptions. To avoid these kinds of leaks and exception problems altogether, use the mechanisms that are provided by the C++ Standard Template Library (STL). These include [shared_ptr](/cpp/standard-library/shared-ptr-class), [unique_ptr](/cpp/standard-library/unique-ptr-class), and [vector](/cpp/standard-library/vector). For more information, see [Smart Pointers](/cpp/cpp/smart-pointers-modern-cpp) and [C++ Standard Library](/cpp/standard-library/cpp-standard-library-reference).
