Reviewed By: skcho Differential Revision: D13048352 fbshipit-source-id: f0a2dc7a4master
parent
2a60a988e7
commit
42b16d45fa
@ -0,0 +1,27 @@
|
||||
/*
|
||||
* 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 do_two_times_Good(int n) {
|
||||
char a[1];
|
||||
for (int i = 0; i < n; i++) {
|
||||
n = 1;
|
||||
a[i] = 3;
|
||||
}
|
||||
}
|
||||
|
||||
void do_two_times2_Good(int n) {
|
||||
char a[1];
|
||||
int k = n;
|
||||
for (int i = 0; i < k; i++) {
|
||||
k = 1;
|
||||
a[i] = 3;
|
||||
}
|
||||
}
|
||||
|
||||
void call_do_two_times_Good_FP() { do_two_times_Good(5); }
|
||||
|
||||
void call_do_two_times2_Good_FP() { do_two_times2_Good(5); }
|
@ -0,0 +1,31 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
#include <vector>
|
||||
|
||||
namespace CppIsTricky {
|
||||
void vector_size_Bad() {
|
||||
const auto vec = std::vector<int>{1, 2, 3};
|
||||
const int numExpectedElements = 1;
|
||||
const auto delta = numExpectedElements - vec.size();
|
||||
}
|
||||
|
||||
void minus1_Bad_FN() {
|
||||
const unsigned long i2 = 18446744073709551614u;
|
||||
const unsigned long i1 = 446744073709551614u;
|
||||
const int d1 = i2 - i1;
|
||||
}
|
||||
void minus2_Bad_FN() {
|
||||
const unsigned long i2 = 18446744073709551614u;
|
||||
const unsigned long i1 = 446744073709551614u;
|
||||
const long d2 = i2 - i1;
|
||||
}
|
||||
void minus3_Good() {
|
||||
const unsigned long i2 = 18446744073709551614u;
|
||||
const unsigned long i1 = 446744073709551614u;
|
||||
const auto d3 = i2 - i1;
|
||||
}
|
||||
} // namespace CppIsTricky
|
Loading…
Reference in new issue