DCHECK causes undeclared identifier error in jumbo build and android-binary-size build |
||||
Issue descriptionI think it is intended that this should compile with DCHECKs disabled: #if DCHECK_IS_ON() int foo = 1; #endif DCHECK(foo); However, I got "use of undeclared identifier" compile errors on linux-jumbo-rel and android-binary-size trybots here: https://chromium-review.googlesource.com/c/chromium/src/+/1370484/1 I'm not sure why the jumbo build behaves differently than non-jumbo builds.
,
Dec 11
The following revision refers to this bug: https://chromium.googlesource.com/chromium/src.git/+/9c995a82acfcfc47c8650c5edea8e5e6c28d7893 commit 9c995a82acfcfc47c8650c5edea8e5e6c28d7893 Author: James Darpinian <jdarpinian@chromium.org> Date: Tue Dec 11 22:00:24 2018 gpu: Change CHECK to DCHECK in transfer buffer As requested in the review of https://crrev.com/c/1336753. After https://crbug.com/913996 is fixed we can remove outstanding_result_pointer_ entirely when DCHECKs are disabled. It also turns out that we can't use the string argument to ASSERT_DEATH to detect a CHECK message in a test because the message strings are stripped in official builds. Bug: 905890, 913421 , 913996 Change-Id: Ia7df19057564ef7a4bbbab9ba36f583c6e6bca0f Reviewed-on: https://chromium-review.googlesource.com/c/1370484 Commit-Queue: James Darpinian <jdarpinian@chromium.org> Reviewed-by: Kenneth Russell <kbr@chromium.org> Cr-Commit-Position: refs/heads/master@{#615680} [modify] https://crrev.com/9c995a82acfcfc47c8650c5edea8e5e6c28d7893/gpu/command_buffer/client/transfer_buffer.cc [modify] https://crrev.com/9c995a82acfcfc47c8650c5edea8e5e6c28d7893/gpu/command_buffer/client/transfer_buffer_unittest.cc
,
Dec 11
,
Dec 12
,
Dec 12
If you get the same error in android-binary-size the common factor is probably not jumbo but some "race condition" that gets triggered when you shake the build up a bit.
The way we define DCHECK, I actually don't know how this should ever work.
base/logging.h says:
// DCHECK et al. make sure to reference |condition| regardless of
// whether DCHECKs are enabled; this is so that we don't get unused
// variable warnings if the only use of a variable is in a DCHECK.
// This behavior is different from DLOG_IF et al.
and defines DCHECK, when turned off to:
#define DCHECK(condition) EAT_STREAM_PARAMETERS << !(condition)
EAT_STREAM_PARAMETERS is
#define EAT_STREAM_PARAMETERS \
true ? (void)0 \
: ::logging::LogMessageVoidify() & (*::logging::g_swallow_stream)
Which I clearly don't understand, but either way, the variable will remain in the code that the compiler sees.
So that
#if DCHECK_IS_ON()
int foo = 1;
#endif
DCHECK(foo);
becomes
true ? (void)0 \
: ::logging::LogMessageVoidify() & (*::logging::g_swallow_stream) << !(foo);
where foo is an undeclared symbol. So how does this not cause compilation errors in most builds? And what is different with linux-jumbo-rel and android-binary-size?
|
||||
►
Sign in to add a comment |
||||
Comment 1 by jdarpinian@chromium.org
, Dec 11