Avoid undefined behavior with msvc compiler (src/include/port/pg_bitutils.h) - Mailing list pgsql-hackers

From Ranier Vilela
Subject Avoid undefined behavior with msvc compiler (src/include/port/pg_bitutils.h)
Date
Msg-id CAEudQAoDhUZyKGJ1vbMGcgVUOcsixe-=jcVaDWarqkUg163D2w@mail.gmail.com
Whole thread Raw
Responses Re: Avoid undefined behavior with msvc compiler (src/include/port/pg_bitutils.h)
List pgsql-hackers
Hi,

The pg_leftmost_one_pos32 function with msvc compiler,
relies on Assert to guarantee the correct result.

But msvc documentation [1] says clearly that
undefined behavior can occur.

Fix by checking the result of the function to avoid
a possible undefined behavior.

patch attached.

best regards,
Ranier Vilela

Attachment

pgsql-hackers by date:

Previous
From: Tomas Vondra
Date:
Subject: Re: logical decoding and replication of sequences, take 2
Next
From: Tomas Vondra
Date:
Subject: Re: logical decoding and replication of sequences, take 2