On Sun, Nov 17, 2024 at 02:50:39AM +0000, Sam James wrote: > With upcoming GCC 15, a new warning is added > (-Wunterminated-string-initialization) that fires when building git: > ``` > CC object-file.o > object-file.c:52:9: warning: initializer-string for array of ‘unsigned char’ is too long [-Wunterminated-string-initialization] > 52 | "\x6e\xf1\x9b\x41\x22\x5c\x53\x69\xf1\xc1" \ > | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > object-file.c:79:17: note: in expansion of macro ‘EMPTY_TREE_SHA256_BIN_LITERAL’ > 79 | .hash = EMPTY_TREE_SHA256_BIN_LITERAL, > | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > object-file.c:61:9: warning: initializer-string for array of ‘unsigned char’ is too long [-Wunterminated-string-initialization] > 61 | "\x47\x3a\x0f\x4c\x3b\xe8\xa9\x36\x81\xa2" \ > | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > object-file.c:83:17: note: in expansion of macro ‘EMPTY_BLOB_SHA256_BIN_LITERAL’ > 83 | .hash = EMPTY_BLOB_SHA256_BIN_LITERAL, > | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > ``` > > Context for the new warning is at https://gcc.gnu.org/PR115185. I think the warning is a false positive for us, but I don't begrudge them for adding it. It could definitely catch real problems. Here are some patches. The first one should fix the warning (but I don't have gcc-15 handy to test!). Please let me know if it works for you (and thank you for reporting). The others are cleanups and future-proofing I found in the same area. Not strictly required, but IMHO worth doing. +cc brian since I think this is a continuation of some hash-algo cleanups he did earlier, plus he piped up in the other gcc-15 thread. ;) [1/5]: object-file: prefer array-of-bytes initializer for hash literals [2/5]: object-file: drop confusing oid initializer of empty_tree struct [3/5]: object-file: move empty_tree struct into find_cached_object() [4/5]: object-file: drop oid field from find_cached_object() return value [5/5]: object-file: inline empty tree and blob literals object-file.c | 77 ++++++++++++++++++++++++--------------------------- 1 file changed, 36 insertions(+), 41 deletions(-)