Direct answer: Type x; default-initializes and can leave int and pointer members holding leftover garbage, while Type x{}; value-initializes and zeroes members before any constructor runs. = default asks the compiler to generate the constructor under the language's own rules. Initialize every member explicitly and prefer braces at call sites.

Two lines of C++ that look interchangeable create different objects. One can hand you an int full of whatever bits that memory held last; the other hands you a zero. The distinction has formal names, and code that ignores it collects bugs that show up only in release builds.

The trending query In C++, = default and {} are not the same constructor made the Hacker News front page in late November 2026, and the surprise in the discussion is the point. Initialization is a place where C++ keeps two separate laws, and which law applies decides whether a member starts at zero or at garbage.

Two modes of creation

Default-initialization is what Type x; does. For a class type it runs the default constructor, and inside that constructor built-in members such as ints and pointers keep indeterminate values unless the code sets them. An indeterminate value can be anything the previous user of that memory left behind.

Value-initialization is what Type x{}; does. Members are zero-initialized before any constructor body runs, so an int starts at 0 and a pointer starts as null. This is why braces look like they reset things: in this mode they do.

Type x;members unsetindeterminate valuesType x{};zero-filled firstthen constructor runssame type, two creation laws

Where = default fits, and where an empty body differs

Writing MyType() = default; asks the compiler to generate the default constructor. The generated version preserves the ordinary member rules: class-type members construct themselves, and built-in members follow whatever the creation mode says, including any default member initializers you declared.

An empty constructor body you type by hand behaves differently in one important way. The compiler treats it as user-provided, and a user-provided constructor takes over the job completely: the empty braces run no member-initializing code and zero nothing. Call-site braces still value-initialize in front of compiler-generated constructors, so the two spellings diverge exactly when you believed they matched.

DeclarationModeBuilt-in member start value
Type x;Default-initializationIndeterminate unless set
Type x{};Value-initializationZero, before any constructor body
MyType() = default;Compiler-generated constructorNormal member rules preserved
MyType() {}User-written empty bodyNothing extra is zeroed
missedyour Brain mapquiz yourselfmasteredWatch your weak spots turn green.

Drop in your PDF - it doesn't leave your device.
Every miss becomes a red node on your map.
Free plan: 21 nodes, no card, no countdown.

Open Brain - free

How the difference bites real code

The classic failure is one struct used in two files. In the first, a developer writes Config c; and it works because that memory happened to be fresh. In the second, the identical line reads whatever bytes the allocator returned, and a pointer member ends up pointing somewhere arbitrary.

Debug builds often scrub memory, and optimized release builds frequently skip that work, so the bug hides until the code ships. The pattern is recognizable in bug reports: a field that is sometimes zero and sometimes garbage, with the difference tracking the build type or the order of earlier allocations.

A rule set that closes the hole

Five habits cover nearly every case and make the brace style a matter of taste:

  1. Give every built-in member a default member initializer, such as int count = 0;, right in the class definition.
  2. Use = default when you want the compiler's constructor, and write a body only when it runs real code.
  3. Prefer Type x{}; at call sites so value-initialization backs you up.
  4. Pass a constructor argument whenever a member has no sensible default.
  5. Build with uninitialized-use warnings enabled, since they catch leftovers the braces cannot.

Key takeaways

  • Type x; default-initializes: built-in members without initializers hold indeterminate values.
  • Type x{}; value-initializes: members are zeroed before any constructor body runs.
  • = default generates the standard constructor and preserves member rules; an empty body zeroes nothing.
  • A user-written empty constructor changes value-initialization behavior for that type, so lookalike spellings diverge.
  • Default member initializers make both creation modes agree and retire the bug class.

Quick answers

Are = default and an empty {} body interchangeable?
No. The generated constructor preserves normal member rules, while the empty body zeroes nothing and counts as user-provided.

What does value-initialization do?
It zero-initializes members before any constructor body runs, which is why braces look like a reset.

Why did my pointer hold garbage?
A plain declaration default-initialized it, and nothing in the constructor or the member list ever set it.

Why does the bug appear only in release?
Debug builds often scrub memory and optimized builds skip that work, so garbage survives to production.

What is the safest style?
Default member initializers on every built-in member, braces at call sites, and warnings for uninitialized use turned on.

One thing to do tonight

Open one struct or class in your own code and add an explicit initializer to every int, pointer, and bool member, then rebuild with warnings raised. If the compiler flags an uninitialized read, the two-laws rule just caught a real bug before your users did.