Repository navigation
Conversation
randen_engine() delegated with randen_engine(0). The int literal is an
exact match for the forwarding SeedSequence&& constructor, so it was
chosen over randen_engine(result_type), and its seed(seq) call then
converted int to the unsigned result_type. That triggers
-Wsign-conversion, which breaks builds of code that default-constructs
the engine with ABSL_LLVM_FLAGS and -Werror.
Pass result_type{0} so the intended constructor is used. Both paths end
in seed(0), so the output is unchanged.
|
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
iwang-1
force-pushed
the
randen-engine-default-ctor
branch
from
November 18, 2026 23:01
f24fec5 to
b2d3830
Compare
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.
randen_engine()delegates withranden_engine(0). The literal0is anint, so overload resolution picks the forwardingtemplate <class SeedSequence> randen_engine(SeedSequence&&)constructor (an exact match forint) instead ofexplicit randen_engine(result_type). That constructor then callsseed(seq)with anint, which converts to the unsignedresult_typeand triggers-Wsign-conversion(part of-WconversioninABSL_LLVM_FLAGS).Any translation unit that default-constructs a
randen_engineand compiles with Abseil's LLVM flags plus-Werrorfails to build. In this repository that includesabsl/random/internal/nanobenchmark.ccandabsl/random/internal/randen_benchmarks.cc:This change passes
result_type{0}, so the default constructor delegates toranden_engine(result_type)as intended. Both paths end inseed(0), so the engine's output is unchanged.Testing: on macOS (Apple clang 17, arm64), a program that default-constructs
randen_engine<uint32_t>andranden_engine<uint64_t>failed to compile withABSL_LLVM_FLAGSand-Werror=sign-conversionbefore this change and compiles after it. In both versions, the first 1000 outputs of a default-constructed engine match an engine constructed with0u.🤖 Generated with Claude Code