FileSystem/Archives: fix narrowing and aggregate-init portability (AppleClang/libc++)#3076
Merged
sprunk merged 2 commits intoJun 30, 2026
Merged
Conversation
…pleClang/libc++) The archive readers build their entry vectors with emplace_back() of an aggregate struct, which relies on parenthesised aggregate initialisation (P0960R3). AppleClang 15 / libc++ does not fully implement it, so the emplace_back calls fail to compile. Switch to push_back() with brace-initialisation, which works on every compiler. Brace-init is stricter about narrowing, so add explicit casts to the declared member types (UInt32/UInt64/uLong -> int/uint32_t). The stored values are unchanged: the previous paren-init converted to the same member types implicitly. push_back() returns void rather than a reference, so use fileEntries.back() instead of capturing the result. No behavioural change on platforms that already compiled. Files: DirArchive.cpp, SevenZipArchive.cpp, ZipArchive.cpp Ports the code fixes from ExaDev/RecoilEngine commits 0095a7e, bba6321 and bc0457c (CI/runner changes deliberately excluded).
Collaborator
|
Static casts look fine. |
n-morales
reviewed
Jun 29, 2026
| const auto& fd = fileEntries.emplace_back( | ||
| i, //fp | ||
| SzArEx_GetFileSize(&db, i), // size | ||
| fileEntries.push_back(FileEntry{ |
Contributor
There was a problem hiding this comment.
Suggested change
| fileEntries.push_back(FileEntry{ | |
| const auto& fd = fileEntries.emplace_back(FileEntry{ |
You could just do this
n-morales noted push_back + fileEntries.back() can collapse back into a single emplace_back. Passing a single brace-initialised FileEntry/Files object avoids the parenthesised-aggregate-init (P0960R3) path that AppleClang/libc++ rejects, while emplace_back's returned reference (C++17) restores the named fd binding and drops the extra back() lookup. Applied to the SevenZip and Zip readers, and to the Dir reader for consistency.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Fix three small portability issues in the VFS archive readers that break compilation under AppleClang / libc++, while remaining correct on every compiler. They touch overlapping files, so they land as one PR.
The archive readers build their entry vectors with
emplace_back()of an aggregate struct (FileEntry/Files). That relies on parenthesised aggregate initialisation (P0960R3), which AppleClang 15 / libc++ does not fully implement, so theemplace_backcalls fail to compile.Changes
emplace_back(...)topush_back(T{...})brace-initialisation, which works on every compiler.UInt32/UInt64/uLong->int/uint32_t). Brace-init is stricter about narrowing than paren-init; the stored values are identical, since the old paren-init performed the same conversions implicitly.fileEntries.back()instead of capturing the call result:push_back()returnsvoid, not a reference to the inserted element.Files:
rts/System/FileSystem/Archives/DirArchive.cpprts/System/FileSystem/Archives/SevenZipArchive.cpprts/System/FileSystem/Archives/ZipArchive.cppNo behavioural change on platforms that already compiled.
Provenance
Ports the code fixes from ExaDev/RecoilEngine commits
0095a7e5c5,bba6321b05,bc0457cf7b. The CI/runner (macos-15) changes in those commits are deliberately excluded as fork-specific.Testing
mastermatches the base those commits applied against.FileEntry.fp/sizeareint,crc/modTimeareuint32_t;Filesis{string, string, int32_t, uint32_t}) — every cast is value-preserving.archivestarget build (gcc-16 and clang, arm64 macOS) is currently blocked by an unrelatedstreflop_cond.hsqrtferror under the macOS SDK that affects every translation unit in the target (including files untouched here); that is being addressed separately. The changes here introduce no compile errors of their own up to that point.Human verification of a full build on a fixed toolchain is still required before merge.
AI disclosure
These changes were extracted and ported with AI assistance (Claude Code). The diffs were reviewed by a human; the verification limitation above is stated honestly and has not been worked around.