diff --git a/docs/error-messages/compiler-errors-1/compiler-error-c2469.md b/docs/error-messages/compiler-errors-1/compiler-error-c2469.md index 46ce44d6ee..836e2ea262 100644 --- a/docs/error-messages/compiler-errors-1/compiler-error-c2469.md +++ b/docs/error-messages/compiler-errors-1/compiler-error-c2469.md @@ -1,23 +1,42 @@ --- -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: 07/23/2025 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) was passed an invalid type. + +## Example: Wrong allocation type + +Check if you meant to allocate `void` or some other type, such as `int`: -An operator was passed an invalid type. +```cpp +// C2469_wrong_allocation_type.cpp + +int main() +{ + int* ptr1 = new void; // C2469 + int* ptr2 = new int; // OK +} +``` + +## Example: Allocate untyped memory -The following sample generates C2469: +If you meant to allocate untyped memory, use `::operator new` instead: ```cpp -// C2469.cpp -int main() { - int *i = new void; // C2469 - int *i = new int; // OK +// C2469_allocate_untyped_memory.cpp + +int main() +{ + void* ptr1 = new void; // C2469 + void* ptr2 = ::operator new(4); // OK } ```