diff --git a/src/fileFormats/ensight/file/ensightFile.C b/src/fileFormats/ensight/file/ensightFile.C index 8f9b28d555bb5a0cb47b44f7ebf7121bdfab2be2..ac552d911db8145569dd005384bb9c2b990f50a6 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) {