Avoid undefined behavior with msvc compiler (src/include/port/pg_bitutils.h)
Ranier Vilela <ranier.vf@gmail.com>
From: Ranier Vilela <ranier.vf@gmail.com>
To: Pg Hackers <pgsql-hackers@postgresql.org>
Date: 2023-07-29T12:37:19Z
Lists: pgsql-hackers
Attachments
- 0001-Avoid-undefined-behavior-with-msvc-compiler.patch (application/octet-stream) patch 0001
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 [1] https://learn.microsoft.com/en-us/cpp/intrinsics/bitscanreverse-bitscanreverse64?view=msvc-170
Commits
-
Bring some MSVC asserts in line with other platforms
- 39055cb4ccd5 17.0 landed