mirror of
https://github.com/isocpp/CppCoreGuidelines.git
synced 2025-12-18 13:14:40 +03:00
CP.1: Made "bad" example consistent with now-updated "good" example
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
# <a name="main"></a>C++ Core Guidelines
|
# <a name="main"></a>C++ Core Guidelines
|
||||||
|
|
||||||
January 28, 2021
|
March 11, 2021
|
||||||
|
|
||||||
|
|
||||||
Editors:
|
Editors:
|
||||||
@@ -13927,10 +13927,10 @@ However, over time, code fragments can turn up in unexpected places.
|
|||||||
|
|
||||||
##### Example, bad
|
##### Example, bad
|
||||||
|
|
||||||
double cached_computation(double x)
|
double cached_computation(int x)
|
||||||
{
|
{
|
||||||
// bad: these statics cause data races in multi-threaded usage
|
// bad: these statics cause data races in multi-threaded usage
|
||||||
static double cached_x = 0.0;
|
static int cached_x = 0.0;
|
||||||
static double cached_result = COMPUTATION_OF_ZERO;
|
static double cached_result = COMPUTATION_OF_ZERO;
|
||||||
|
|
||||||
if (cached_x != x) {
|
if (cached_x != x) {
|
||||||
|
|||||||
Reference in New Issue
Block a user