Reviewed By: jvillard Differential Revision: D26126418 fbshipit-source-id: e3e24c3dcmaster
parent
d375a6c03e
commit
b289d240f5
@ -0,0 +1,37 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||||
|
*
|
||||||
|
* This source code is licensed under the MIT license found in the
|
||||||
|
* LICENSE file in the root directory of this source tree.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <stdbool.h>
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
|
void assign_implicit_cast_ok() {
|
||||||
|
bool* b = (bool*)malloc(sizeof(bool));
|
||||||
|
uint16_t i = 1;
|
||||||
|
if (b) {
|
||||||
|
*b = true;
|
||||||
|
*b = !i;
|
||||||
|
if (*b) {
|
||||||
|
int* p = 0;
|
||||||
|
*p = 5;
|
||||||
|
}
|
||||||
|
free(b);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void assign_implicit_cast_bad() {
|
||||||
|
bool* b = (bool*)malloc(sizeof(bool));
|
||||||
|
uint16_t i = 0;
|
||||||
|
if (b) {
|
||||||
|
*b = false;
|
||||||
|
*b = !i;
|
||||||
|
if (*b) {
|
||||||
|
int* p = 0;
|
||||||
|
*p = 5;
|
||||||
|
}
|
||||||
|
free(b);
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in new issue