Re: New compiler warnings in buildfarm

From: Ranier Vilela <ranier(dot)vf(at)gmail(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: Re: New compiler warnings in buildfarm
Date: 2024-07-30 16:56:16
Message-ID: CAEudQApxfgRjnwqUw=pyAB4pkL9pUrAVDwN4eNMBUVjaeVE0Fg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Em ter., 30 de jul. de 2024 às 13:19, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> escreveu:

> Sometime in the last month or so, flaviventris's bleeding-edge
> version of gcc has started whining[1] about truncation of a
> string literal's implicit trailing '\0' in contexts like this:
>
> ../pgsql/src/backend/commands/copyto.c:106:41: warning: initializer-string
> for array of 'char' is too long [-Wunterminated-string-initialization]
> 106 | static const char BinarySignature[11] = "PGCOPY\n\377\r\n\0";
> | ^~~~~~~~~~~~~~~~~~~~
>
> ../pgsql/src/backend/utils/adt/numutils.c:29:1: warning:
> initializer-string for array of 'char' is too long
> [-Wunterminated-string-initialization]
> 29 | "00" "01" "02" "03" "04" "05" "06" "07" "08" "09"
> | ^~~~
>
> Presumably this'll appear in less-bleeding-edge releases in a
> few months' time.
>
> In the BinarySignature case, we could silence it in at least two ways.
> We could remove the explicit trailing \0 and rely on the implicit one:
>
> -static const char BinarySignature[11] = "PGCOPY\n\377\r\n\0";
> +static const char BinarySignature[11] = "PGCOPY\n\377\r\n";
>
> Or just drop the unnecessary array length specification:
>
+1 for dropping the length specification.
The trailing \0 the compiler will automatically fill in.
Note this came from copyfromparse.c, who also have the same problem.

best regards,
Ranier Vilela

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Melih Mutlu 2024-07-30 17:19:30 Do we still need parent column in pg_backend_memory_context?
Previous Message Robert Haas 2024-07-30 16:38:40 Re: Suboptimal spinlock code due to volatile