[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Unhealthy commit e3340714c8 Style: clarify "do nothing" macro with {
From: |
Graham Percival |
Subject: |
Re: Unhealthy commit e3340714c8 Style: clarify "do nothing" macro with {}; |
Date: |
Thu, 7 Oct 2010 21:17:33 +0100 |
On Thu, Oct 7, 2010 at 8:36 PM, David Kastrup <address@hidden> wrote:
>
> -#define ASSERT_LIVE_IS_ALLOWED()
> +#define ASSERT_LIVE_IS_ALLOWED() {};
>
> The problem is that the replaced statement defines
> ASSERT_LIVE_IS_ALLOWED() as being 1, while the second defines it as {};.
> That is a particular bad idea for things like
>
> if (condition) ASSERT_LIVE_IS_ALLOWED(); else ...
My understanding was that this is a debugging construct which is only
used as a function call. I mean, the "non-else" definition of
ASSERT_LIVE would also run into problems in that construct:
#ifndef NDEBUG
#define ASSERT_LIVE_IS_ALLOWED() \
static bool passed_here_once;\
if (parsed_objects_should_be_dead && !passed_here_once) { \
::programming_error (string ("Parsed object should be dead: ") +
__PRETTY_FUNCTION__ ); \
passed_here_once = true;\
}
#else
#define ASSERT_LIVE_IS_ALLOWED() {};
#endif
in that the macro might look like a single statement, but it gets
expanded into two. (is it worth enclosing the non-else definition
with a { } to avoid this?)
> So either ASSERT_LIVE_IS_ALLOWED() should be explicitly defined as 1.
I'm fine with that change, if it makes sense given the non-else
definition. I'm kind-of out of my depth here.
Cheers,
- Graham