On Mon, 2017-01-09 at 16:51 +0000, Adel Boutros wrote:
> Hello Alan,
> 
> 
> I had provided in one of my previous emails in this discussion a
> simple test case which fails. What we noticed is that this failure
> occurs when we have 2 bool fields. It doesn't occur with a single
> bool.
> 
> It seems that on Solaris with SunStudio 12.1 the wrong byte is
> changed when setting one of the bools when 2 consecutive bool fields
> have bitfields activated.
> 
> 
> If you really find bit fields important, we can try to separate the 2
> bools (Having another field between them) and it should work.

I'm not worried about this case, your fix is fine. I'm concerned about
the broader question of ceasing to use bit fields always and forever in
my professional life case Solaris explodes :)

Separating bitfields defeats the purpose which is to get the compiler
to pack multiple boolean flags or very small integer values into a
single byte/word/long word.

Is the Solaris problem just with bool? Traditional C use would be

  int flag:1;

does that work on Solaris? I'm guessing it does.

I used bool for stylistic reasons, but I'll switch to the more
tranditional int now that I know it's a possible portability issue.
bool is a recent introduction to C and the degree to which bool is
"like" and "not like" the traditional int and char types has caused no
end of confusion.

> 
> 
> Regards,
> 
> Adel
> 
> ________________________________
> From: Alan Conway <[email protected]>
> Sent: Monday, January 9, 2017 5:37:27 PM
> To: [email protected]
> Subject: Re: [Proton 0.16.0] [Solaris] Unit tests hanging when
> destroying connection_driver
> 
> On Wed, 2017-01-04 at 10:39 -0500, Andrew Stitcher wrote:
> > On Wed, 2017-01-04 at 14:47 +0000, Adel Boutros wrote:
> > > I found the issue!!
> > > 
> > > 
> > > It is a Solaris compiler bug:
> > > 
> > > Actually Solaris doesn't handle correctly bit fields in C. This
> > > is
> > > the case of the struct pn_collector_t (bool head_returned:1).
> 
> Huh? What?? Bitfields have been a standard part of C since forever. I
> am astonished.
> 
> > We probably should just never be using bifields in this case - it
> > is
> > pretty unusual in my experience (even if it seems like it would
> > save
> > space in the struct).
> > 
> 
> They're not used often because people tend to be too busy to think
> about struct packing, but they are an important perf tuning tool. It
> can be the difference between a single bool packing into 1 bit at
> best
> vs 64 at worst. That can easily double the size of a small structure
> that gets allocated by the millions, or force cache misses on the
> critical path. It often is not very important but sometimes it really
> is.
> 
> > So I, for one, would definitely accept a patch to remove all uses
> > of
> > bool bitfields.
> 
> If existing bit fields can be removed without performance impact to
> fix
> a bug then I'm OK with that too, but a blanket ban on bit fields
> seems
> unreasonable. Can we narrow the scope of the actual Solaris problem
> to
> something smaller than "bitfields are broken, don't ever use them"?
> I'm
> pretty sure that can't be the case.
> 
> Cheers,
> Alan.
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [email protected]
> For additional commands, e-mail: [email protected]
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to