icu
icu copied to clipboard
ICU-22911 Fix coverity warning in numrange_fluent.cpp
See: https://unicode-org.atlassian.net/browse/ICU-22911
Checklist
- [x] Required: Issue filed: https://unicode-org.atlassian.net/browse/ICU-22911
- [x] Required: The PR title must be prefixed with a JIRA Issue number.
- [x] Required: The PR description must include the link to the Jira Issue, for example by completing the URL in the first checklist item
- [x] Required: Each commit message must be prefixed with a JIRA Issue number.
- [x] Issue accepted (done by Technical Committee after discussion)
- [ ] Tests included, if applicable
- [ ] API docs and/or User Guide docs changed or added, if applicable
@sffc OK, so that means that the coverity warning is a false positive, right? That is reassuring.
But would my patch help to avoid the coverity warning, or is is wrong? Or should a cmment to suppress the coverity warning be added?
The patch as it currently stands is wrong; @markusicu explained why here: https://github.com/unicode-org/icu/pull/3202#discussion_r1772486159
It might be that there's a way to write this code that doesn't trigger the coverity warning, and doing so would be nice if possible. I'm not that familiar with how Coverity works.
The patch as it currently stands is wrong; @markusicu explained why here: #3202 (comment)
It might be that there's a way to write this code that doesn't trigger the coverity warning, and doing so would be nice if possible. I'm not that familiar with how Coverity works.
I don't know much about coverity either. Adding this comment might remove the coverity warning:
--- a/icu4c/source/i18n/numrange_fluent.cpp
+++ b/icu4c/source/i18n/numrange_fluent.cpp
@@ -239,6 +239,7 @@ LocalizedNumberRangeFormatter::LocalizedNumberRangeFormatter(LocalizedNumberRang
LocalizedNumberRangeFormatter::LocalizedNumberRangeFormatter(NFS<LNF>&& src) noexcept
: NFS<LNF>(std::move(src)) {
// Steal the compiled formatter
+ // coverity[use_after_move]
LNF&& _src = static_cast<LNF&&>(src);
auto* stolen = _src.fAtomicFormatter.exchange(nullptr);
delete fAtomicFormatter.exchange(stolen);