diff --git a/src/fileFormats/ensight/file/ensightFile.C b/src/fileFormats/ensight/file/ensightFile.C index 5163cc09424a313fe0c1d25e7dc559ed1f82edf9..168be050449c0895caf336387b08ac71373fd300 100644 --- a/src/fileFormats/ensight/file/ensightFile.C +++ b/src/fileFormats/ensight/file/ensightFile.C @@ -165,8 +165,15 @@ Foam::Ostream& Foam::ensightFile::write Foam::Ostream& Foam::ensightFile::write(const char* value) { + // Parentheses around strncpy to silence the GCC -Wstringop-truncation + // warning, which is spurious here. + // The max-size and buffer-size *are* identical, which means the buffer + // may not have a nul terminator. However, this is properly handled in + // the subsequent binary write and the ASCII write explicitly adds + // a nul terminator. + char buf[80]; - strncpy(buf, value, 80); // max 80 chars or padded with nul if smaller + (strncpy(buf, value, 80)); // max 80 chars or padded with nul if smaller if (format() == IOstream::BINARY) {