Ray's Knowledge Base
Unlock

A budget that hardcodes std::string size passes on macOS libc++ and fails on libstdc++

PitfallVerified 5 Oct 2026Holds project: dftracer-utils
Pitfall. The symptom, what causes it, and the fix that was run and seen to work.

Symptom#

A test or layout budget passes on the macOS libc++ dev build but fails in the GCC 12 container with a static assertion failed: str... or a budget mismatch.

Cause#

sizeof(std::string) and the SSO capacity differ between the libraries (32 on libstdc++, 24 on libc++).

Fix#

Compute memory budgets and layout expectations from sizeof(std::string) or the string's length, never from a constant measured on macOS.

Evidence#

Fixed in commit 5a12a75a; only docker-test-gcc12 shows it.

Also found by searching

  • static assertion failed str... only in docker-test-gcc12
  • sizeof std::string differs between libc++ and libstdc++
  • memory budget test passes on macOS fails in GCC 12 container
  • layout budget hardcodes std::string size