Re: NULL passed as an argument to memcmp() in parse_func.c - Mailing list pgsql-hackers

From Tom Lane
Subject Re: NULL passed as an argument to memcmp() in parse_func.c
Date
Msg-id 7856.1434999322@sss.pgh.pa.us
Whole thread Raw
In response to NULL passed as an argument to memcmp() in parse_func.c  (Piotr Stefaniak <postgres@piotr-stefaniak.me>)
Responses Re: NULL passed as an argument to memcmp() in parse_func.c  (Piotr Stefaniak <postgres@piotr-stefaniak.me>)
Re: NULL passed as an argument to memcmp() in parse_func.c  (Robert Haas <robertmhaas@gmail.com>)
Re: NULL passed as an argument to memcmp() in parse_func.c  (Piotr Stefaniak <postgres@piotr-stefaniak.me>)
List pgsql-hackers
Piotr Stefaniak <postgres@piotr-stefaniak.me> writes:
> There are two places in parse_func.c where memcmp() conditionally gets a 
> NULL as its first argument, which invokes undefined behavior. I guess 
> gcc -O2 will make some assumptions based on memcpy's __nonnull attribute.

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.  Are
you seeing any observable problem here, and if so what is it?
        regards, tom lane



pgsql-hackers by date:

Previous
From: Jim Nasby
Date:
Subject: Re: Further issues with jsonb semantics, documentation
Next
From: Piotr Stefaniak
Date:
Subject: Re: NULL passed as an argument to memcmp() in parse_func.c