Subject: Re: [boost] gcc4.3 warning for multiple scope exits
From: Kim Barrett (kab.conundrums_at_[hidden])
Date: 2009-07-14 11:28:26


At 1:38 PM +0000 7/14/09, Alexander Nasonov wrote:
>This is crazy, isn't it?

No kidding!

>Q: correctly indent the following code: <see code above>
>A: it's impossible
>
>For the second use, the correct indentation is:
>
>boost::scope_exit::aux::holder<
> boost::scope_exit::aux::declare<
> sizeof(boost_scope_exit_args)
> >::apply < 0
> >::apply_value > boost_scope_exit_args;

Yes. (I *think*. See discussion of "crazy" above.)

>They're the same because void* is well aligned and there is no padding
>in struct apply<0> but strictly speaking, they don't have to be of equal
>size.

Hm. Everything involved looks like POD to me (albeit with oddly spelled
names, if one is a C programmer). I think lots of code would be broken
if such types could be different in size. But I admit I can't right now
put together a string of text in the standard that would guarantee that
they are the same size.

> I like explicit specializations for declared and undeclared, though.
>They make reading code a little bit easier (and here "a little bit" make
>a big difference, given how complex the trick is).

Completely agree.

>Perhaps adding BOOST_STATIC_ASSERT would be enough?

I don't see any way that could hurt. Even if not necessary, it may help
guide future readers in the right direction.