From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | Piotr Stefaniak <postgres(at)piotr-stefaniak(dot)me> |
Cc: | PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: NULL passed as an argument to memcmp() in parse_func.c |
Date: | 2015-06-22 19:17:34 |
Message-ID: | 8816.1435000654@sss.pgh.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
Piotr Stefaniak <postgres(at)piotr-stefaniak(dot)me> writes:
> On 06/22/2015 08:55 PM, Tom Lane wrote:
>> If I recall that code correctly, the assumption was that if the third
>> argument is zero then memcmp() must not fetch any bytes (not should not,
>> but MUST not) and therefore it doesn't matter if we pass a NULL.
> It's not about fetching any bytes, it's about passing an invalid pointer
> (a null pointer in this case) which gives a compiler the opportunity to
> apply an optimization. For example, glibc has memcpy marked as
> __nonnull(1,2).
If they do, that's a glibc bug, per the above observation.
regards, tom lane
From | Date | Subject | |
---|---|---|---|
Next Message | Piotr Stefaniak | 2015-06-22 19:27:06 | Re: NULL passed as an argument to memcmp() in parse_func.c |
Previous Message | Piotr Stefaniak | 2015-06-22 19:15:35 | Re: NULL passed as an argument to memcmp() in parse_func.c |