Repository navigation
Fix nvcc C++17 compile with std::back_insert_iterator (fixes #5046) - #5049
Open
Tyagiquamar wants to merge 1 commit into
Open
Tyagiquamar wants to merge 1 commit into
Tyagiquamar wants to merge 1 commit into
Conversation
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.
Summary
fmt::format_to(std::back_inserter(...), ...).FMT_CONSTEXPR20ondetail::get_container()and its localaccessorconstructor, matching pre-12.2 behavior under C++17 (whereback_insert_iteratoris not a literal type).format_towithstd::back_inserter.Root cause
Commit e99ef3f ("Relax constexpr") marked
get_containerandaccessorasconstexprin all language modes. Under C++17, libstdc++'sstd::back_insert_iteratorconstructor is notconstexpr, so nvcc's EDG front end rejects theaccessorbase constructor even though GCC accepts the unused template specialization (see #5046).Solution
In
include/fmt/core.h, useFMT_CONSTEXPR20forget_containerandaccessor, so these functions are onlyconstexprwhen the library enables C++20 constexpr extensions (same approach as fmt 12.1.0).Test plan
test/cuda-test/cuda-cpp14.cuandtest/cuda-test/cpp14.cc(format_to+back_inserter).gcc:14-bookwormbuilds on this machine.linux/windows/macosworkflows; optionalcuda-testwhenFMT_CUDA_TESTis enabled.Fixes #5046.