Re: Pointer subtraction with a null pointer

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Andres Freund <andres(at)anarazel(dot)de>
Cc: pgsql-hackers(at)lists(dot)postgresql(dot)org, Robert Haas <robertmhaas(at)gmail(dot)com>, Thomas Munro <thomas(dot)munro(at)gmail(dot)com>
Subject: Re: Pointer subtraction with a null pointer
Date: 2022-03-26 18:13:56
Message-ID: 103098.1648318436@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Andres Freund <andres(at)anarazel(dot)de> writes:
> Wonder if we should try to get rid of the problem by also fixing the double
> evaluation of val? I think something like

Good idea. The attached also silences the warning, and getting rid
of the double-eval hazard seems like a net win.

> Might also be worth adding an assertion that base < val.

Did that too. On the whole I like this better.

regards, tom lane

Attachment Content-Type Size
silence-null-subtraction-warning-2.patch text/x-diff 1.2 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tomas Vondra 2022-03-26 18:15:37 Re: Column Filtering in Logical Replication
Previous Message Andres Freund 2022-03-26 18:08:59 Re: Pointer subtraction with a null pointer