CHECK/DCHECK: Explicitly state whether the condition can have side effects

R=andrew@webrtc.org

Review URL: https://webrtc-codereview.appspot.com/24889004

git-svn-id: http://webrtc.googlecode.com/svn/trunk@7394 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
kwiberg@webrtc.org 2014-10-08 12:19:56 +00:00
parent 5e3d7c78de
commit 9c6dc46c6d

View File

@ -35,6 +35,9 @@
// she recognizes that if she is wrong, abrupt and unpleasant process
// termination is still better than carrying on with the assumption violated.
//
// CHECK always evaluates its argument, so it's OK for x to have side
// effects.
//
// - DCHECK(x) is the same as CHECK(x)---an assertion that x is always
// true---except that x will only be evaluated in debug builds; in production
// builds, x is simply assumed to be true. This is useful if evaluating x is
@ -46,6 +49,10 @@
// at night knowing that the process will suicide instead of carrying on in
// case you were wrong, use CHECK instead of DCHECK.
//
// DCHECK only evaluates its argument in debug builds, so if x has visible
// side effects, you need to write e.g.
// bool w = x; DCHECK(w);
//
// - CHECK_EQ, _NE, _GT, ..., and DCHECK_EQ, _NE, _GT, ... are specialized
// variants of CHECK and DCHECK that print prettier messages if the condition
// doesn't hold. Prefer them to raw CHECK and DCHECK.