From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | pgsql-hackers(at)lists(dot)postgresql(dot)org |
Subject: | New string-truncation warnings from GCC 15 |
Date: | 2025-09-16 22:48:07 |
Message-ID: | 1404372.1758062887@sss.pgh.pa.us |
Views: | Whole Thread | Raw Message | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
Several of the buildfarm animals seem to have been updated to
GCC 15 over the past week or so. They are now moaning about
various places where we're intentionally omitting a string
terminator, eg these warnings from scorpion:
scorpion | 2025-09-16 18:39:03 | ../pgsql/src/backend/commands/copyfromparse.c:139:41: warning: initializer-string for array of 'char' truncates NUL terminator but destination lacks 'nonstring' attribute (12 chars into 11 available) [-Wunterminated-string-initialization]
scorpion | 2025-09-16 18:39:03 | ../pgsql/src/backend/commands/copyto.c:109:41: warning: initializer-string for array of 'char' truncates NUL terminator but destination lacks 'nonstring' attribute (12 chars into 11 available) [-Wunterminated-string-initialization]
scorpion | 2025-09-16 18:39:03 | ../pgsql/src/backend/utils/adt/encode.c:152:1: warning: initializer-string for array of 'char' truncates NUL terminator but destination lacks 'nonstring' attribute (513 chars into 512 available) [-Wunterminated-string-initialization]
scorpion | 2025-09-16 18:39:03 | ../pgsql/src/backend/utils/adt/numutils.c:30:1: warning: initializer-string for array of 'char' truncates NUL terminator but destination lacks 'nonstring' attribute (201 chars into 200 available) [-Wunterminated-string-initialization]
scorpion | 2025-09-16 18:39:03 | ../pgsql/contrib/fuzzystrmatch/daitch_mokotoff.c:92:20: warning: initializer-string for array of 'char' truncates NUL terminator but destination lacks 'nonstring' attribute (7 chars into 6 available) [-Wunterminated-string-initialization]
These are not bugs, but it'd be a good idea to silence the
warnings somehow.
Plan A seems to be to do what the warning suggests and add
a "nonstring" marker to these constants. I gather the syntax
is like this:
char a2nonstring[1] __attribute__((nonstring)) = "a";
It's not clear to me how well this approach will play with
non-GCC compilers.
Plan B could be to change the code so that we're not
truncating the implicit \0 characters. It doesn't look
to me like this would involve any large amount of violence
to the logic, but it's a bit less pretty.
Plan B would be a compiler-independent fix, so I mildly favor plan B.
Thoughts?
regards, tom lane
From | Date | Subject | |
---|---|---|---|
Next Message | Andres Freund | 2025-09-16 23:25:10 | Re: New string-truncation warnings from GCC 15 |
Previous Message | Dmitry Koval | 2025-09-16 22:08:17 | Re: Add SPLIT PARTITION/MERGE PARTITIONS commands |