pg.ddx.io  pgsql-hackers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Peter Eisentraut <peter@eisentraut.org>
Cc: Alvaro Herrera <alvherre@alvh.no-ip.org>
Cc: Amit Langote <amitlangote09@gmail.com>
Cc: Erik Rijkers <er@xs4all.nl>
Cc: jian he <jian.universality@gmail.com>
Cc: Andrew Dunstan <andrew@dunslane.net>
Cc: PostgreSQL-development <pgsql-hackers@postgresql.org>
Subject: Re: remaining sql/json patches
Date: Tue, 12 Sep 2023 10:43:41 -0400
Message-ID: <2797648.1694529821@sss.pgh.pa.us> (raw)
In-Reply-To: <d506638e-3f5d-df45-7f11-ac797037253c@eisentraut.org>
References: <202309061501.xcwpfa2jjj5n@alvherre.pgsql>
	<d506638e-3f5d-df45-7f11-ac797037253c@eisentraut.org>

Peter Eisentraut <peter@eisentraut.org> writes:
> On 06.09.23 17:01, Alvaro Herrera wrote:
>> Assert()ing that a pointer is not null, and in the next line
>> dereferencing that pointer, is useless: the process would crash anyway
>> at the time of dereference, so the Assert() adds no value.  Better to
>> leave the assert out.

> I don't think this is quite correct.  If you dereference a pointer, the 
> compiler may assume that it is not null and rearrange code accordingly. 
> So it might not crash.  Keeping the assertion would alter that assumption.

Uh ... only in assert-enabled builds.  If your claim is correct,
this'd result in different behavior in debug and production builds,
which would be even worse.  But I don't believe the claim.
I side with Alvaro's position here: such an assert is unhelpful.

			regards, tom lane





view thread (300+ messages)  latest in thread

Message-ID: <2797648.1694529821@sss.pgh.pa.us>
Permalink:  ../2797648.1694529821@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/2797648.1694529821@sss.pgh.pa.us

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-hackers@postgresql.org
  Cc: tgl@sss.pgh.pa.us, peter@eisentraut.org, alvherre@alvh.no-ip.org, amitlangote09@gmail.com, er@xs4all.nl, jian.universality@gmail.com, andrew@dunslane.net
  Subject: Re: remaining sql/json patches
  In-Reply-To: <2797648.1694529821@sss.pgh.pa.us>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox