Lists: | Postg배트맨 토토SQL |
---|
From: | Sergei Kornilov <sk(at)zsrv(dot)org> |
---|---|
To: | PostgreSQL mailing lists <pgsql-hackers(at)postgresql(dot)org> |
Subject: | complier warnings from ecpg tests |
Date: | 2019-07-11 12:21:15 |
Message-ID: | 14951331562847675@sas2-a1efad875d04.qloud-c.yandex.net |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-hackers |
Hello
I noticed few warnings from my compiler (gcc version 8.3.0 (Debian 8.3.0-6)) during make check-world:
array.pgc: In function ‘main’:
array.pgc:41:16: warning: ‘%d’ directive writing between 1 and 11 bytes into a region of size 10 [-Wformat-overflow=]
sprintf(str, "2000-1-1 0%d:00:00", j);
^~~~~~~~~~~~~~~~~~~~
array.pgc:41:16: note: directive argument in the range [-2147483648, 9]
array.pgc:41:3: note: ‘sprintf’ output between 18 and 28 bytes into a destination of size 20
sprintf(str, "2000-1-1 0%d:00:00", j);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
array.pgc:43:16: warning: ‘sprintf’ may write a terminating nul past the end of the destination [-Wformat-overflow=]
sprintf(str, "2000-1-1%d\n", j);
^~~~~~~~~~~~~~
array.pgc:43:3: note: ‘sprintf’ output between 11 and 21 bytes into a destination of size 20
sprintf(str, "2000-1-1%d\n", j);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
They coming from src/interfaces/ecpg tests ( ./src/interfaces/ecpg/test/sql/array.pgc ).
Seems this code is 4 year old but I did not found discussion related to such compiler warnings. Is this expected?
regards, Sergei
From: | Michael Paquier <michael(at)paquier(dot)xyz> |
---|---|
To: | Sergei Kornilov <sk(at)zsrv(dot)org> |
Cc: | PostgreSQL mailing lists <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: complier warnings from ecpg tests |
Date: | 2019-07-11 13:40:14 |
Message-ID: | 20190711134014.GL4500@paquier.xyz |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-hackers |
On Thu, Jul 11, 2019 at 03:21:15PM +0300, Sergei Kornilov wrote:
> I noticed few warnings from my compiler (gcc version 8.3.0 (Debian
> 8.3.0-6)) during make check-world:
>
> They coming from src/interfaces/ecpg tests (
> ./src/interfaces/ecpg/test/sql/array.pgc ).
> Seems this code is 4 year old but I did not found discussion related
> to such compiler warnings. Is this expected?
Are you using -Wformat-overflow? At which level?
--
Michael
From: | Sergei Kornilov <sk(at)zsrv(dot)org> |
---|---|
To: | Michael Paquier <michael(at)paquier(dot)xyz> |
Cc: | PostgreSQL mailing lists <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: complier warnings from ecpg tests |
Date: | 2019-07-11 13:57:08 |
Message-ID: | 16015021562853428@iva5-fb4da115b4b5.qloud-c.yandex.net |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-hackers |
Hi
> Are you using -Wformat-overflow? At which level?
I use: ./configure --prefix=somepath --enable-cassert --enable-debug CFLAGS="-ggdb -Og -g3 -fno-omit-frame-pointer" --enable-tap-tests
No other explicit options.
pg_config reports:
CPPFLAGS = -D_GNU_SOURCE
CFLAGS = -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Werror=vla -Wendif-labels -Wmissing-format-attribute -Wformat-security -fno-strict-aliasing -fwrapv -fexcess-precision=standard -Wno-format-truncation -Wno-stringop-truncation -g -ggdb -Og -g3 -fno-omit-frame-pointer
CFLAGS_SL = -fPIC
regards, Sergei
From: | Michael Paquier <michael(at)paquier(dot)xyz> |
---|---|
To: | Sergei Kornilov <sk(at)zsrv(dot)org> |
Cc: | PostgreSQL mailing lists <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: complier warnings from ecpg tests |
Date: | 2019-08-01 06:14:06 |
Message-ID: | 20190801061406.GD3435@paquier.xyz |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | Postg토토 캔SQL : |
On Thu, Jul 11, 2019 at 04:57:08PM +0300, Sergei Kornilov wrote:
> I use: ./configure --prefix=somepath --enable-cassert --enable-debug
> CFLAGS="-ggdb -Og -g3 -fno-omit-frame-pointer" --enable-tap-tests
> No other explicit options.
Thanks for the set of flags. So this comes from the use of -Og, and
the rest of the tree does not complain. The issue is that gcc
complains about the buffer not being large enough, but %d only uses up
to 2 characters so there is no overflow. In order to fix the issue it
is fine enough to increase the buffer size to 28 bytes, so I would
recommend to just do that. This is similar to the business done in
3a4b891.
--
Michael
From: | Michael Paquier <michael(at)paquier(dot)xyz> |
---|---|
To: | Sergei Kornilov <sk(at)zsrv(dot)org> |
Cc: | PostgreSQL mailing lists <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: complier warnings from ecpg tests |
Date: | 2019-08-02 00:55:50 |
Message-ID: | 20190802005550.GA1717@paquier.xyz |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-hackers |
On Thu, Aug 01, 2019 at 03:14:06PM +0900, Michael Paquier wrote:
> Thanks for the set of flags. So this comes from the use of -Og, and
> the rest of the tree does not complain. The issue is that gcc
> complains about the buffer not being large enough, but %d only uses up
> to 2 characters so there is no overflow. In order to fix the issue it
> is fine enough to increase the buffer size to 28 bytes, so I would
> recommend to just do that. This is similar to the business done in
> 3a4b891.
And fixed with a9f301d.
--
Michael
From: | Sergei Kornilov <sk(at)zsrv(dot)org> |
---|---|
To: | Michael Paquier <michael(at)paquier(dot)xyz> |
Cc: | PostgreSQL mailing lists <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: complier warnings from ecpg tests |
Date: | 2019-08-02 07:33:31 |
Message-ID: | 29833681564731211@iva1-9be92bdead40.qloud-c.yandex.net |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | Postg배트맨 토토SQL |
Hi
>> Thanks for the set of flags. So this comes from the use of -Og, and
>> the rest of the tree does not complain. The issue is that gcc
>> complains about the buffer not being large enough, but %d only uses up
>> to 2 characters so there is no overflow. In order to fix the issue it
>> is fine enough to increase the buffer size to 28 bytes, so I would
>> recommend to just do that. This is similar to the business done in
>> 3a4b891.
>
> And fixed with a9f301d.
Thank you! My compiler is now quiet
regards, Sergei