We're updating the issue view to help you get more done. 

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

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:

1 2 3 4 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

Status

Assignee

Steven R. Loomis

Components

Fix versions

Priority

major