Repository navigation
Replace nullptr with empty string in ternary expressions - #351
Merged
nikolaygorb merged 1 commit intoOct 9, 2026
Merged
Conversation
nikolaygorb
approved these changes
Oct 9, 2026
DariaMityagina
approved these changes
Oct 9, 2026
Maxim-Doronin
approved these changes
Oct 9, 2026
Collaborator
|
@oToToT sorry for bothering you again with this matter... could you please sign&push again? |
Problem: In C++23 (P2166R1 - A Proposal to Prohibit std::basic_string and std::basic_string_view construction from nullptr), constructing a std::string from nullptr is explicitly deleted: basic_string(nullptr_t) = delete; In `optimize_precision_across_function_calls.cpp`, ternary logging expressions evaluate: (producerCallOp != nullptr) ? producerCallOp->getName().getStringRef().str() : nullptr Under C++23, the common type of `std::string` and `std::nullptr_t` cannot be deduced because `std::string(nullptr)` is deleted, causing: error: non-constant-expression cannot be narrowed from type 'nullptr_t' to 'std::string' Even prior to C++23, passing nullptr to basic_string is an undefined behavior per P2166R1. Hence, regardless of C++23, we should fix it. Solution: Replace `: nullptr` with an empty string literal `: ""` in both ternary expressions.
oToToT
force-pushed
the
fix/ie-nullptr-to-string-cxx23
branch
from
October 9, 2026 12:22
919894a to
1ab6202
Compare
Contributor
Author
|
done. sorry didn't aware of this at the time I create this PR. |
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
Problem:
In C++23 (P2166R1 - A Proposal to Prohibit std::basic_string and std::basic_string_view construction from nullptr), constructing a std::string from nullptr is explicitly deleted:
basic_string(nullptr_t) = delete;
In
optimize_precision_across_function_calls.cpp, ternary logging expressions evaluate:(producerCallOp != nullptr) ? producerCallOp->getName().getStringRef().str() : nullptr
Under C++23, the common type of
std::stringandstd::nullptr_tcannot be deduced becausestd::string(nullptr)is deleted, causing:error: non-constant-expression cannot be narrowed from type 'nullptr_t' to 'std::string'
Even prior to C++23, passing nullptr to basic_string is an undefined behavior per P2166R1. Hence, regardless of C++23, we should fix it.
Solution:
Replace
: nullptrwith an empty string literal: ""in both ternary expressions.JIRA ticket
N/A
Target Platform For Release Notes
Classification of this Pull Request
Related PRs
N/A