Skip to content

Commit bb1f542

Browse files
Merge #818: Add static assertion that uint32_t is unsigned int or wider
c0041b5 Add static assertion that uint32_t is unsigned int or wider (Tim Ruffing) Pull request description: Solves one item in #792 . ACKs for top commit: sipa: utACK c0041b5 elichai: ACK c0041b5 Tree-SHA512: 9f700e89be39e15983260da94642593d16b9c437171e10377837ac73731ca7ba5dd7e328b3d93d0a24d143fb9e73abd11c578f6b58e2f94c82b783e977173b0c
2 parents 5006895 + c0041b5 commit bb1f542

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/assumptions.h

+7-1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
#ifndef SECP256K1_ASSUMPTIONS_H
88
#define SECP256K1_ASSUMPTIONS_H
99

10+
#include <limits.h>
11+
1012
#include "util.h"
1113

1214
/* This library, like most software, relies on a number of compiler implementation defined (but not undefined)
@@ -19,7 +21,11 @@ struct secp256k1_assumption_checker {
1921
allowed. */
2022
int dummy_array[(
2123
/* Bytes are 8 bits. */
22-
CHAR_BIT == 8 &&
24+
(CHAR_BIT == 8) &&
25+
26+
/* No integer promotion for uint32_t. This ensures that we can multiply uintXX_t values where XX >= 32
27+
without signed overflow, which would be undefined behaviour. */
28+
(UINT_MAX <= UINT32_MAX) &&
2329

2430
/* Conversions from unsigned to signed outside of the bounds of the signed type are
2531
implementation-defined. Verify that they function as reinterpreting the lower

0 commit comments

Comments
 (0)