# In C++, = default and {} are not the same constructor

DevFeed: [In C++, = default and {} are not the same constructor](<https://devfeed.tech/articles/in-c-default-and-are-not-the-same-constructor-113364.md>)

Original publisher: [Read original article](<https://lemire.me/blog/2026/11/02/default-and-braces-are-not-the-same-constructor/>)

Author: Daniel Lemire

Published: 2026-11-02T12:48:59Z

Content type: article

Language: en

Sources: [Daniel Lemire](<https://devfeed.tech/sources/daniel-lemire.md>)

Topics: [constructor](<https://devfeed.tech/topics/constructor.md>), [c/c++](<https://devfeed.tech/topics/c-c-plus-plus.md>), [clang](<https://devfeed.tech/topics/clang.md>)

Tags: [c-plus-plus](<https://devfeed.tech/tags/c-plus-plus.md>), [constructor](<https://devfeed.tech/tags/constructor.md>), [gcc](<https://devfeed.tech/tags/gcc.md>), [intel-xeon](<https://devfeed.tech/tags/intel-xeon.md>), [november-2026](<https://devfeed.tech/tags/november-2026.md>), [performance](<https://devfeed.tech/tags/performance.md>), [spans](<https://devfeed.tech/tags/spans.md>), [struct](<https://devfeed.tech/tags/struct.md>)

## AI overview

An empty `span() = default` and `span() {}` can produce different performance because only the first is trivial: the explicitly defaulted constructor is trivial, while the empty body is user-provided. In the shown `box()` path, GCC 16 with `-O2 -march=x86-64` generates direct field stores for `span() {}`, but uses a temporary and copies 16 bytes for `span() = default`. The author reports that in timing tests of 100 million spans on one Intel Xeon Gold 6548N core, the `= default` version was over four times slower with both GCC 15 and GCC 16. The result is tied to the described code, compiler settings, and test setup.

## Source excerpt

You can write an empty default constructor as span() = default or as span() {}. It can have remarkable effects on performance. struct span { const char *p; int len; const char *end; span() = default; // or span() {} span(const char *s, int n) : p(s), len(n), end(s + n) {} }; The constructor ... Continue reading In C++, = default and {} are not the same constructor