Uploaded image for project: 'ICU'
  1. ICU-20244

Fix gcc stringop-overflow warning/error in uloc.cpp

    Details

    • Type: Bug
    • Status: Done (View workflow)
    • Priority: major
    • Resolution: Fixed
    • Affects versions: None
    • Fix versions: 64.1
    • Components: build_c
    • Labels:
      None

      Description

      Hi,

      When building with LTO support and -Wall -Wextra -Werror, you might end up in your final program having build errors in ICO code:

      uloc.cpp: In function ‘_ZL13_canonicalizePKcPcijP10UErrorCode.part.9’:
      uloc.cpp:1741: error: ‘strncpy’ specified bound depends on the length of the source argument [-Werror=stringop-overflow=]
      uloc.cpp:1738: note: length computed here
      lto1: all warnings being treated as errors
      

      gcc simply complains that it is not so efficient to use strncpy using the exact lenght of the string computed by memcpy, since it will check for end of string uselessly. Instead using memcpy has the same behavior and is more efficient since it doesn't check the end of string.

      This is fixed in https://github.com/unicode-org/icu/pull/246

      Cheers,
      Romain

        Attachments

          Activity

            People

            • Assignee:
              srl295 Steven R. Loomis
              Reporter:
              Anonymous
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: