Re: Clang UndefinedBehaviorSanitize (Postgres14) Detected undefined-behavior

From: Alvaro Herrera <alvherre(at)2ndquadrant(dot)com>
To: Ranier Vilela <ranier(dot)vf(at)gmail(dot)com>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Peter Geoghegan <pg(at)bowt(dot)ie>, Noah Misch <noah(at)leadboat(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: Clang UndefinedBehaviorSanitize (Postgres14) Detected undefined-behavior
Date: 2020-08-31 17:00:50
Message-ID: 20200831170050.GA3569@alvherre.pgsql
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 2020-Aug-31, Ranier Vilela wrote:

> More troubles with undefined-behavior.
>
> This type of code can leaves overflow:
> var = (cast) (expression);
> diff = (int32) (id1 - id2);
>
> See:
> diff64 = ((long int) d1 - (long int) d2);
> diff64=-4294901760

Did you compile this with gcc -fwrapv?

--
Álvaro Herrera https://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Bruce Momjian 2020-08-31 17:08:17 Re: Ideas about a better API for postgres_fdw remote estimates
Previous Message Neha Sharma 2020-08-31 16:57:31 Re: PATCH: logical_work_mem and logical streaming of large in-progress transactions