---
id: 1951
title: "Use constexpr for faster, smaller, and safer code"
source_domain: blog.trailofbits.com
source_url: "https://blog.trailofbits.com/2019/06/27/use-constexpr-for-faster-smaller-and-safer-code/"
published_at: "2019-06-27T10:50:06Z"
tags: ["static-analysis", "cpp", "compilers", "mitigations", "undefined-behavior", "constexpr"]
phying_url: "https://phying.com/item/1951"
lang: en
---

# Use constexpr for faster, smaller, and safer code

## Summary

Because constexpr code cannot invoke undefined behavior, C++14 constexpr eliminates bug classes like silently optimized overflow checks while shrinking binaries. A libclang tool automates this.

## Intelligence Metadata

- **Sources:** blog.trailofbits.com
- **Published:** 2019-06-27T10:50:06Z
- **Original:** https://blog.trailofbits.com/2019/06/27/use-constexpr-for-faster-smaller-and-safer-code/
- **Phying News:** https://phying.com/item/1951
