Re: Undefined behavior detected by new clang's ubsan

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: John Naylor <johncnaylorls(at)gmail(dot)com>
Cc: Alexander Lakhin <exclusion(at)gmail(dot)com>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Undefined behavior detected by new clang's ubsan
Date: 2026-01-20 18:52:08
Message-ID: 1710697.1768935128@sss.pgh.pa.us
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

John Naylor <johncnaylorls(at)gmail(dot)com> writes:
> I don't think it's great to pass a NULL pointer to a sort, but the
> length could conceivably be zero for future degenerate cases, so we
> could silence the warning by adding "if (n < 2) return;" before the
> for-loop. The advantage of doing that anyway is it allows us to remove
> all four of the "if (d_ > ST_POINTER_STEP)" branches in the recursion
> part. That's better for readability.

+1

regards, tom lane

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2026-01-20 18:55:31 Re: commented out code
Previous Message Matheus Alcantara 2026-01-20 18:48:11 Re: support ALTER COLUMN SET EXPRESSION over virtual generated column with check constraint