Skip to content

Conversation

@philipp-zimmermann
Copy link

Changes

The rvalue overloads for icu::UnicodeString::tempSubString and icu::UnicodeString::tempSubStringBetween are deleted.

Justification

Calling tempSubString on a rvalue violates the precondition ("[...] requires that the original string not be modified or deleted during the lifetime of the returned substring object."). Therefore disallowing usage like this prevents bugs.

A example for the buggy behavior is the following code:

#include <iostream>
#include <unicode/unistr.h>

[[nodiscard]] auto get_string() -> icu::UnicodeString
{
  return icu::UnicodeString {"abcdefg"};
}

auto print (icu::UnicodeString const& unicode_string) -> void
{
  std::string s;
  unicode_string.toUTF8String (s);
  std::cout << s << '\n';
}

int main()
{
  {
    auto const substring {get_string().tempSubString(2)};

    print (substring);
    std::string s;
    substring.toUTF8String (s);
    std::cout << s << '\n';
    print (substring);
  }

  std::cout << "\nCorrect behavior:\n";

  {
    auto const full_string {get_string()};
    auto const substring {full_string.tempSubString(2)};

    print (substring);
    std::string s;
    substring.toUTF8String (s);
    std::cout << s << '\n';
    print (substring);
  }
}

This may lead to output like this:

cdefg
efg
晥gg

Correct behavior:
cdefg
cdefg
cdefg

The above output is from a binary compiled with "Release" mode. When using "Debug" the behavior is correct.
This is tested with https://github.com/unicode-org/icu/releases/download/release-78.2/icu4c-78.2-Ubuntu22.04-x64.tgz.

Jira issue

I am not able to create a new jira issue at all and I'm not able to find a solution for this problem.

TODO: Fill out the checklist below.

Checklist

  • Required: Issue filed: ICU-NNNNN
  • Required: The PR title must be prefixed with a JIRA Issue number. Example: "ICU-NNNNN Fix xyz"
  • Required: Each commit message must be prefixed with a JIRA Issue number. Example: "ICU-NNNNN Fix xyz"
  • Issue accepted (done by Technical Committee after discussion)
  • [x ] Tests included, if applicable
  • API docs and/or User Guide docs changed or added, if applicable
  • Approver: Feel free to merge on my behalf

@CLAassistant
Copy link

CLAassistant commented Jan 13, 2026

CLA assistant check
All committers have signed the CLA.

@markusicu
Copy link
Member

@philipp-zimmermann please sign the CLA. Otherwise we can't look at your proposed changes.
Note that ICU API is stable; we cannot simply remove public, stable API.

I am not able to create a new jira issue at all and I'm not able to find a solution for this problem.

You need to create a Jira account before you can create a ticket. See https://icu.unicode.org/bugs

@philipp-zimmermann
Copy link
Author

@philipp-zimmermann please sign the CLA. Otherwise we can't look at your proposed changes. Note that ICU API is stable; we cannot simply remove public, stable API.

I am not able to create a new jira issue at all and I'm not able to find a solution for this problem.

You need to create a Jira account before you can create a ticket. See https://icu.unicode.org/bugs

Thanks for the Answer.

I still have the issue that the Button "+ Create" is red for me and nothing happens when I click on it. I tried the following things to fix the problem:

  • I used my gmail account as well as a newly created account directly on jira.
  • I tried disabling all addons on firefox. (on ubuntu)
  • I tried it with the jira account on windows and a default edge browser.
  • I tried using the google account on windows with a default chrome browser.

Nothing worked so far.

@markusicu
Copy link
Member

We have had a couple of other people also report problems with Jira; we are looking into that.

We can create a Jira ticket on your behalf, but we can't look at your changes until you sign the CLA.

@philipp-zimmermann
Copy link
Author

We have had a couple of other people also report problems with Jira; we are looking into that.

We can create a Jira ticket on your behalf, but we can't look at your changes until you sign the CLA.

Hi Markus,
Thanks for looking into the issue.

I forgot to add the mail address associated to the commit to my github account. Now it recognizes that I signed the CLA.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants