mirror of
https://github.com/openjdk/jdk.git
synced 2026-05-11 14:11:36 +00:00
8178348: left_n_bits(0) invokes undefined behavior
Reviewed-by: dholmes, coleenp
This commit is contained in:
parent
0b10c6b415
commit
4b5c664b4c
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2020, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1997, 2021, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -390,6 +390,3 @@ STATIC_ASSERT(nth_bit(1|2) == 0x8);
|
||||
|
||||
STATIC_ASSERT(right_n_bits(3) == 0x7);
|
||||
STATIC_ASSERT(right_n_bits(1|2) == 0x7);
|
||||
|
||||
STATIC_ASSERT(left_n_bits(3) == (intptr_t) LP64_ONLY(0xE000000000000000) NOT_LP64(0xE0000000));
|
||||
STATIC_ASSERT(left_n_bits(1|2) == (intptr_t) LP64_ONLY(0xE000000000000000) NOT_LP64(0xE0000000));
|
||||
|
||||
@ -982,7 +982,6 @@ const intptr_t OneBit = 1; // only right_most bit set in a word
|
||||
// (note: #define used only so that they can be used in enum constant definitions)
|
||||
#define nth_bit(n) (((n) >= BitsPerWord) ? 0 : (OneBit << (n)))
|
||||
#define right_n_bits(n) (nth_bit(n) - 1)
|
||||
#define left_n_bits(n) (right_n_bits(n) << (((n) >= BitsPerWord) ? 0 : (BitsPerWord - (n))))
|
||||
|
||||
// bit-operations using a mask m
|
||||
inline void set_bits (intptr_t& x, intptr_t m) { x |= m; }
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user