Skip to content
This repository was archived by the owner on Oct 23, 2023. It is now read-only.

Commit dd97f13

Browse files
author
Josh MacDonald
committed
Fix for kTargetNodeSize too large
1 parent 1a14ff5 commit dd97f13

File tree

3 files changed

+20
-19
lines changed

3 files changed

+20
-19
lines changed

‎btree.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1435,6 +1435,11 @@ class btree : public Params::key_compare {
14351435
sizeof(key_compare_checker(key_compare_helper()(key_type(), key_type()))) ==
14361436
sizeof(base::big_),
14371437
key_comparison_function_must_return_bool);
1438+
1439+
// Note: We insist on kTargetValues, which is computed from
1440+
// Params::kTargetNodeSize, falling under 256 because of the uint8
1441+
// fields of base_fields.
1442+
COMPILE_ASSERT(kNodeValues < 256, target_node_size_too_large);
14381443
};
14391444

14401445
////

‎btree_nc.cc

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,11 @@ TEST_COMPARE_TO(int);
4040
#elif defined(TEST_compare_to_float)
4141
TEST_COMPARE_TO(float);
4242
#elif defined(TEST_compare_to_pointer)
43-
TEST_COMPARE_TO(pointer);
43+
TEST_COMPARE_TO(void*);
44+
#elif defined(TEST_large_nodesize)
45+
void LargeNode() {
46+
util::btree::btree_set<int64, less<int64>, std::allocator<int64>, 10000> set;
47+
}
4448
#endif
4549

4650
} // namespace

‎btree_nc_test.py

Lines changed: 10 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -30,45 +30,37 @@ def testCompilerErrors(self):
3030

3131
# Test that int does not work as a return type for key comparison.
3232
('int',
33-
[r'error: creating array with negative size', # for gcc
34-
r'', # for icc
35-
]),
33+
[r'key_comparison_function_must_return_bool']),
3634

3735
# Test that float does not work as a return type for key comparison.
3836
('float',
39-
[r'error: creating array with negative size', # for gcc
40-
r'', # for icc
41-
]),
37+
[r'key_comparison_function_must_return_bool']),
4238

4339
# Test that void* does not work as a return type for key comparison.
4440
('pointer',
45-
[r'error: creating array with negative size', # for gcc
46-
r'', # for icc
47-
]),
41+
[r'key_comparison_function_must_return_bool']),
4842

4943
# Test that bool does not work as a return type for compare-to
5044
# comparison.
5145
('compare_to_bool',
52-
[r'error: creating array with negative size', # for gcc
53-
r'', # for icc
54-
]),
46+
[r'key_comparison_function_must_return_bool']),
5547

5648
# Test that int works as a return type for compare-to comparison.
5749
('compare_to_int', None), # None means compilation should succeed.
5850

5951
# Test that float does not work as a return type for compare-to
6052
# comparison.
6153
('compare_to_float',
62-
[r'error: creating array with negative size', # for gcc
63-
r'', # for icc
64-
]),
54+
[r'key_comparison_function_must_return_bool']),
6555

6656
# Test that void* does not work as a return type for compare-to
6757
# comparison.
6858
('compare_to_pointer',
69-
[r'error: creating array with negative size', # for gcc
70-
r'', # for icc
71-
]),
59+
[r'key_comparison_function_must_return_bool']),
60+
61+
# Test that large node sizes do not compile.
62+
('large_nodesize',
63+
[r'target_node_size_too_large']),
7264
]
7365

7466
# Runs the list of tests.

0 commit comments

Comments
 (0)