---
name: "std::bad_alloc"
section: "3"
platform: "linux"
package: "gcc"
version: "16.2.1+r23+gd564253eb6c8-1"
release: "Arch Linux 2026-11-01"
platforms: ["linux"]
url: "https://new.carta.tech/std::bad_alloc"
---

# std::bad\_alloc(3)

Exception possibly thrown by new.

## NAME

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

## SYNOPSIS

\#include \<new\_except.h\>

Inherits **std::exception**.

### Public Member Functions

\_GLIBCXX26\_CONSTEXPR **bad\_alloc** (const bad\_alloc &)=default\
 \_GLIBCXX26\_CONSTEXPR bad\_alloc & **operator=** (const bad\_alloc &)=default\
 virtual constexpr const char \* **what** () const noexcept\

## 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 constexpr const char \* std::bad\_alloc::what () const \[inline\], \[constexpr\], \[virtual\], \[noexcept\]

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.
