Lists: | pgsql-hackers |
---|
From: | Peter Eisentraut <peter_e(at)gmx(dot)net> |
---|---|
To: | pgsql-hackers(at)postgresql(dot)org |
Subject: | add -Wlogical-op to standard compiler options? |
Date: | 2012-11-15 06:17:10 |
Message-ID: | 1352960230.19890.3.camel@vanquo.pezone.net |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-hackers |
I think it might be worth adding -Wlogical-op to the standard warning
options (for supported compilers, determined by configure test).
`-Wlogical-op'
Warn about suspicious uses of logical operators in expressions.
This includes using logical operators in contexts where a bit-wise
operator is likely to be expected.
In addition to what it says there, it appears to warn about illogical
combinations of < and >. I have been using it locally for a while
without problems. We have already found a couple of bugs this way.
From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | Peter Eisentraut <peter_e(at)gmx(dot)net> |
Cc: | pgsql-hackers(at)postgresql(dot)org |
Subject: | Re: add -Wlogical-op to standard compiler options? |
Date: | 2012-11-15 14:40:41 |
Message-ID: | 14721.1352990441@sss.pgh.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-hackers |
Peter Eisentraut <peter_e(at)gmx(dot)net> writes:
> I think it might be worth adding -Wlogical-op to the standard warning
> options (for supported compilers, determined by configure test).
Does that add any new warnings with the current source code, and if
so what?
regards, tom lane
From: | Peter Eisentraut <peter_e(at)gmx(dot)net> |
---|---|
To: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
Cc: | pgsql-hackers(at)postgresql(dot)org |
Subject: | Re: add -Wlogical-op to standard compiler options? |
Date: | 2012-11-15 21:46:20 |
Message-ID: | 50A562AC.6010501@gmx.net |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-hackers |
On 11/15/12 9:40 AM, Tom Lane wrote:
> Peter Eisentraut <peter_e(at)gmx(dot)net> writes:
>> I think it might be worth adding -Wlogical-op to the standard warning
>> options (for supported compilers, determined by configure test).
>
> Does that add any new warnings with the current source code, and if
> so what?
none
From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | Peter Eisentraut <peter_e(at)gmx(dot)net> |
Cc: | pgsql-hackers(at)postgresql(dot)org |
Subject: | Re: add -Wlogical-op to standard compiler options? |
Date: | 2012-11-15 21:58:23 |
Message-ID: | 23554.1353016703@sss.pgh.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-hackers |
Peter Eisentraut <peter_e(at)gmx(dot)net> writes:
> On 11/15/12 9:40 AM, Tom Lane wrote:
>> Peter Eisentraut <peter_e(at)gmx(dot)net> writes:
>>> I think it might be worth adding -Wlogical-op to the standard warning
>>> options (for supported compilers, determined by configure test).
>> Does that add any new warnings with the current source code, and if
>> so what?
> none
No objection from me then.
regards, tom lane
From: | Jeff Janes <jeff(dot)janes(at)gmail(dot)com> |
---|---|
To: | Peter Eisentraut <peter_e(at)gmx(dot)net> |
Cc: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, pgsql-hackers(at)postgresql(dot)org |
Subject: | Re: add -Wlogical-op to standard compiler options? |
Date: | 2012-11-21 19:46:37 |
Message-ID: | CAMkU=1z+QwjLqcU-ckz5Px3jtU7_wMBquM-5bXQKc6jTM3EWJQ@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-hackers |
On Thu, Nov 15, 2012 at 1:46 PM, Peter Eisentraut <peter_e(at)gmx(dot)net> wrote:
> On 11/15/12 9:40 AM, Tom Lane wrote:
>> Peter Eisentraut <peter_e(at)gmx(dot)net> writes:
>>> I think it might be worth adding -Wlogical-op to the standard warning
>>> options (for supported compilers, determined by configure test).
>>
>> Does that add any new warnings with the current source code, and if
>> so what?
>
> none
Using gcc (GCC) 4.4.6 20120305 (Red Hat 4.4.6-4), I get dozens of
warnings, all apparently coming from somewhere in the MemSet macro.
example:
pl_handler.c:301: warning: logical '&&' with non-zero constant will
always evaluate as true
Probably has something to do with:
/* \
* If MEMSET_LOOP_LIMIT == 0, optimizer
should find \
* the whole "if" false at compile time. \
*/ \
MEMSET_LOOP_LIMIT != 0) \
Cheers,
Jeff
From: | Peter Eisentraut <peter_e(at)gmx(dot)net> |
---|---|
To: | Jeff Janes <jeff(dot)janes(at)gmail(dot)com> |
Cc: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, pgsql-hackers(at)postgresql(dot)org |
Subject: | Re: add -Wlogical-op to standard compiler options? |
Date: | 2012-11-23 21:28:07 |
Message-ID: | 1353706087.4992.0.camel@vanquo.pezone.net |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-hackers |
On Wed, 2012-11-21 at 11:46 -0800, Jeff Janes wrote:
> Using gcc (GCC) 4.4.6 20120305 (Red Hat 4.4.6-4), I get dozens of
> warnings, all apparently coming from somewhere in the MemSet macro.
OK, reverted.
It looks like they dialed it down to a more useful volume in GCC 4.5,
but that doesn't really help us.