Skip to content

Commit 51835df

Browse files
authored
[MSVC] fix the build (#69634)
MSVC in C mode apparently doesn't consider `const int` to be sufficiently constant expression This was broken in #66903.
1 parent a432358 commit 51835df

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

compiler-rt/lib/builtins/int_to_fp.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,10 @@ static __inline int clzSrcT(usrc_t x) { return __clzti2(x); }
4444
typedef float dst_t;
4545
typedef uint32_t dst_rep_t;
4646
#define DST_REP_C UINT32_C
47-
static const int dstSigBits = 23;
47+
48+
enum {
49+
dstSigBits = 23,
50+
};
4851

4952
#elif defined DST_DOUBLE
5053
typedef double dst_t;

compiler-rt/lib/builtins/int_to_fp_impl.inc

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,15 @@
1717
static __inline dst_t __floatXiYf__(src_t a) {
1818
if (a == 0)
1919
return 0.0;
20-
const int dstMantDig = dstSigBits + 1;
21-
const int srcBits = sizeof(src_t) * CHAR_BIT;
22-
const int srcIsSigned = ((src_t)-1) < 0;
20+
21+
enum {
22+
dstMantDig = dstSigBits + 1,
23+
srcBits = sizeof(src_t) * CHAR_BIT,
24+
srcIsSigned = ((src_t)-1) < 0,
25+
};
26+
2327
const src_t s = srcIsSigned ? a >> (srcBits - 1) : 0;
28+
2429
a = (usrc_t)(a ^ s) - s;
2530
int sd = srcBits - clzSrcT(a); // number of significant digits
2631
int e = sd - 1; // exponent

0 commit comments

Comments
 (0)