---
name: "std::bad_cast"
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_cast/3cxx"
---

# std::bad\_cast(3cxx)

Thrown during incorrect typecasting.

## NAME

std::bad\_cast - Thrown during incorrect typecasting.

## SYNOPSIS

`#include <typeinfo>`

Inherits **std::exception**.

Inherited by **std::bad\_any\_cast**, and **std::experimental::fundamentals\_v1::bad\_any\_cast**.

### Public Member Functions

**virtual** const char \* **what** () const noexcept\

## Detailed Description

Thrown during incorrect typecasting.

If you attempt an invalid `dynamic_cast` expression, an instance of this class (or something derived from this class) is thrown. \

## Member Function Documentation

### virtual const char \* std::bad\_cast::what () const` [virtual]`, ` [noexcept]`

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

Reimplemented from **std::exception**.

Reimplemented in **std::bad\_any\_cast**, and **std::experimental::fundamentals\_v1::bad\_any\_cast**.

## Author

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