Summary: The aligned width of bool should be 1-byte, while the range of bool [0,1]. Reviewed By: jvillard Differential Revision: D12932394 fbshipit-source-id: be1a5d6d1master
parent
86f52e52ed
commit
72ce05c039
@ -0,0 +1,30 @@
|
||||
/*
|
||||
* Copyright (c) 2018-present, Facebook, Inc.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
void sizeof_bool_Good() {
|
||||
int a[2];
|
||||
int z = sizeof(bool); // z is 1 (byte)
|
||||
a[z] = 0;
|
||||
}
|
||||
|
||||
void sizeof_bool_Bad() {
|
||||
int a[1];
|
||||
int z = sizeof(bool); // z is 1 (byte)
|
||||
a[z] = 0;
|
||||
}
|
||||
|
||||
// FP due to incomplete frontend translation of casting
|
||||
void range_bool_Good_FP() {
|
||||
int a[2];
|
||||
bool x = true + true; // x is 1 (true)
|
||||
a[x] = 0;
|
||||
}
|
||||
|
||||
void range_bool_Bad() {
|
||||
int a[1];
|
||||
bool x = true + false; // x is 1 (true)
|
||||
a[x] = 0;
|
||||
}
|
Loading…
Reference in new issue