---
name: "std::bad_alloc"
section: "3cxx"
platform: "linux"
package: "libstdc++-12-doc"
version: "12.4.0-5"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/std::bad_alloc/3cxx"
---

# std::bad\_alloc(3cxx)

Exception possibly thrown by new.

## NAME

std::bad\_alloc - Exception possibly thrown by `new`.

## SYNOPSIS

`#include <new>`

Inherits **std::exception**.

Inherited by std::bad\_array\_new\_length.

### Public Member Functions

**bad\_alloc** (const **bad\_alloc** &)=**default**\
 **bad\_alloc** & **operator=** (const **bad\_alloc** &)=**default**\
 **virtual** const char \* **what** () const  **throw** ()\

## Detailed Description

Exception possibly thrown by `new`.

`bad_alloc` (or classes derived from it) is used to report allocation errors from the throwing forms of `new`. \

## Member Function Documentation

### virtual const char \* std::bad\_alloc::what () const` [virtual]`

Returns a C-style character string describing the general cause of the current error. \

Reimplemented from **std::exception**.

## Author

Generated automatically by Doxygen for libstdc++ from the source code.
