Every code block in P4222R3 (Stroustrup, 2026-10-22, "An initialization profile") is reproduced below, compiled under the profile on the two implementations the paper cites as "tested nightly" [Impl1, Impl2], with what the paper says should happen beside what does. Where a block needed scaffolding to be a translation unit (a definition of X, a declaration of my_malloc, a fix to a typo) the addition is marked in a comment; lines added to probe a consequence the paper does not spell out are marked // added.
The whole set was rechecked on 2026-11-14: every listing recompiled and compared, and each claim in the prose that goes beyond a listing tried with a small program of its own. The listings all stood. Some of the prose did not, and where a passage changed it carries a bracketed note beginning "Revised 2026-11-14" that says what the first version said.
Compilers, as built on Compiler Explorer on the date above:
- Clang
- CE id
clang_profiles_init, built from cppalliance/clang branch profiles-init at commit 4a2d2673 (2026-10-15), an llvm-project fork based on main of 2026-07-20. Flags -std=c++23 -pedantic-errors.
- GCC
- CE id
gcontracts-p4324-trunk, built from villevoutilainen/gcc branch p4324 at commit 146e7ba1 (2026-10-24/25), based on trunk of 2026-07-18. Same flags. [Revised 2026-11-14: Compiler Explorer rebuilds this compiler from the branch, and by the recheck it was at commit a9bec5e9 (2026-11-13). All 36 examples give the same diagnostics on that build. The Clang build had not changed.]
The profile is enabled in each case by the file-scope [[profiles::enforce(std::init)]]; from P3589; -fprofiles-enforce=std::init works on both as well.
Each Compiler Explorer link opens the source on the left and, for each compiler, the compiler pane with its diagnostics pane directly beneath it. Line numbers in the diagnostics match the numbered source blocks.
The examples are grouped by how badly the paper and the implementations disagree, worst first: rejected by both compilers where the paper says OK; rejected by Clang where the paper says OK; accepted by Clang where the paper says error; GCC alone differing; and the examples where both compilers agree with the paper. Within a group the examples follow the paper's order unless noted. The summary table at the end lists all 36 in the paper's order.
Of 36 examples, the two implementations give the same verdicts on 20 (and nearly so on 1 more); on the other 15 they disagree with each other, in most cases on lines the paper annotates. [Revised 2026-11-14: the first version had 18, 2 and 16. In §5.3 Label and §5.4 classes without constructors GCC's extra error against the type turned out to be its report of the same line Clang rejects.] Nine of the paper's examples are rejected by both compilers on a line the paper marks OK; they are the first group below, led by the §4.7 Vector the paper calls "guaranteed free from initialization errors". In two of the nine (§4.9 uninitialized_fill, §5.5 arrays) the paper's own text contradicts the annotation.
Three recurring causes account for most of the differences:
- GCC does not know the standard library.
malloc returns initialized memory to it (§4.3 malloc/calloc note, §4.7 Vector, §4.11 malloc/new, §5.3 exposing uninitialized), and so does new int (§4.9 unique_ptr/vector); a second construct_at or destroy_at of the same object goes unnoticed (§4.6 destroy_at); std::uninitialized_fill and free are unannotated and so reject marked arguments (§4.7 Vector). Clang knows these by builtin ID. [Revised 2026-11-14: the first version said construct_at and destroy_at were unmodelled on GCC, and listed the §4.9 example under malloc, which it does not call. construct_at is modelled: GCC accepts std::construct_at(&x, 10) on an [[uninit]] local and a read of x after it, where the same address passed to an unannotated function template is an error. What GCC does not do is notice the second one.]
- GCC implements
[[ref_to_uninit]] on pointers and references only: not on class-type handles (§4.6 construct_at, Appendix settled forms), not on a read through a marked return value (§4.5 Slot), and not on a reference bound to a local (§4.3 f1/f2/g). Clang implements all of these. [Revised 2026-11-14: the first version said "not on return types". GCC does check where a marked returned pointer is stored (§4.3 malloc/calloc); it is a read through the returned pointer or reference that it lets by. The Appendix placement example was also cited for references to locals, and it has none.]
- The attribute vocabulary has forked: the paper's
[[must_init]] is unknown to Clang, which implements [[now_init]]; GCC implements [[must_init]] but on the parameter rather than in the paper's function position (§4.2 must_init, Appendix settled forms). std::now_init ships in GCC's <utility> and nowhere in Clang's library (§1.4 now_init to a span).