https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88059
Rangel Moreira Fischer changed:
What|Removed |Added
CC||rangel_fischer at yahoo dot
com.br
--- Comment #4 from Rangel Moreira Fischer
---
Same problem too.
static void write_my_message( char* message, size_t max_message_size, char*
my_message )
{
size_t messag_len = strlen(my_message) + 1;
if( messag_len > max_message_size )
{
// trunc message
strncpy(message, my_message, max_message_size - 1); // ex:
max_message_size = max buf size = 50(0 to 49). 0 to 48 = 49
elements(max_message_size - 1).
message[max_message_size - 1] = '\0'; // message[50-1] = message[49] =
'\0'.
}
else
{
strncpy(message, my_message, messag_len);
}
}
In function 'write_my_message':
error: 'strncpy' specified bound depends on the length of the source argument
[-Werror=stringop-overflow=]
strncpy(message, my_message, messag_len);
^~~~
note: length computed here
size_t messag_len = strlen(my_message) + 1;
^~