Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 25 additions & 10 deletions docs/error-messages/compiler-errors-1/compiler-error-c2469.md
Original file line number Diff line number Diff line change
@@ -1,23 +1,38 @@
---
description: "Learn more about: Compiler Error C2469"
title: "Compiler Error C2469"
ms.date: "11/04/2016"
description: "Learn more about: Compiler Error C2469"
ms.date: 2/27/2026
f1_keywords: ["C2469"]
helpviewer_keywords: ["C2469"]
ms.assetid: 3814bdff-581a-4d3e-8b47-8de6887cea69
---
# Compiler Error C2469

'operator': cannot allocate 'type' object
> '`new`': cannot allocate '`void`' objects

## Remarks

The [`new` operator](../../cpp/new-operator-cpp.md) allocates memory and constructs an object of the specified type. Since `void` isn't a constructible type, use `::operator new(size)` to allocate raw memory without object construction.

## Example: Wrong allocation type

```cpp
// compile with /c
int main()
{
void* ptr1 = new void; // C2469
int* ptr2 = new int; // OK
}
```

An operator was passed an invalid type.
## Example: Allocate untyped memory

The following sample generates C2469:
To allocate untyped memory, use `::operator new`:

```cpp
// C2469.cpp
int main() {
int *i = new void; // C2469
int *i = new int; // OK
// compile with /c
int main()
{
void* ptr1 = new void; // C2469
void* ptr2 = ::operator new(4); // OK
}
```