Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit39055cb

Browse files
committed
Bring some MSVC asserts in line with other platforms
MSVC's _BitScan* functions return a boolean indicating whether anybits were set in the input, and we were previously asserting thatthey returned true, per our API. This is correct. However, otherplatforms simply assert that the input is non-zero, so do that to bemore consistent.Noted while investigating a hypothesis from Ranier Vilela aboutundefined behavior, but this is not his proposed patch.Discussion:https://www.postgresql.org/message-id/CAEudQAoDhUZyKGJ1vbMGcgVUOcsixe-%3DjcVaDWarqkUg163D2w%40mail.gmail.com
1 parent7395a90 commit39055cb

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

‎src/include/port/pg_bitutils.h

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,9 @@ pg_leftmost_one_pos32(uint32 word)
4848
unsigned longresult;
4949
boolnon_zero;
5050

51+
Assert(word!=0);
52+
5153
non_zero=_BitScanReverse(&result,word);
52-
Assert(non_zero);
5354
return (int)result;
5455
#else
5556
intshift=32-8;
@@ -85,8 +86,9 @@ pg_leftmost_one_pos64(uint64 word)
8586
unsigned longresult;
8687
boolnon_zero;
8788

89+
Assert(word!=0);
90+
8891
non_zero=_BitScanReverse64(&result,word);
89-
Assert(non_zero);
9092
return (int)result;
9193
#else
9294
intshift=64-8;
@@ -116,8 +118,9 @@ pg_rightmost_one_pos32(uint32 word)
116118
unsigned longresult;
117119
boolnon_zero;
118120

121+
Assert(word!=0);
122+
119123
non_zero=_BitScanForward(&result,word);
120-
Assert(non_zero);
121124
return (int)result;
122125
#else
123126
intresult=0;
@@ -156,8 +159,9 @@ pg_rightmost_one_pos64(uint64 word)
156159
unsigned longresult;
157160
boolnon_zero;
158161

162+
Assert(word!=0);
163+
159164
non_zero=_BitScanForward64(&result,word);
160-
Assert(non_zero);
161165
return (int)result;
162166
#else
163167
intresult=0;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp