[chromium-dev] Re: Quick question about struct initialization

2009-03-23 Thread Tommi
; -Original Message- > > From: chromium-dev@googlegroups.com [mailto:chromium- > > d...@googlegroups.com] On Behalf Of Book'em Dano > > Sent: Sunday, March 22, 2009 11:30 AM > > To: Chromium-dev > > Subject: [chromium-dev] Re: Quick question about struct initializ

[chromium-dev] Re: Quick question about struct initialization

2009-03-22 Thread Markus Gutschke
The only time where this does not quite work is if the very first field in the struct/class is not a POD that can be initialized to zero. A common example would be "struct sigaction" on Linux. The first field is an anonymous union holding both sa_handler and sa_sigaction. So, this code wouldn't co

[chromium-dev] Re: Quick question about struct initialization

2009-03-22 Thread Avi Drissman
On Sun, Mar 22, 2009 at 5:10 PM, Adam Langley wrote: > struct s a = {0}; will initialise all members of the structure to zero. > Correct. The C++ Standard, §12.6.1 (Explicit initialization) paragraph 2 says: When an aggregate (whether class or array) contains members of class type > and is init

[chromium-dev] Re: Quick question about struct initialization

2009-03-22 Thread Adam Langley
On Sun, Mar 22, 2009 at 11:36 AM, Paul Topping wrote: > Your {0} initialization only inits the first element of the struct struct s a = {0}; will initialise all members of the structure to zero. AGL --~--~-~--~~~---~--~~ Chromium Developers mailing list: chromi

[chromium-dev] Re: Quick question about struct initialization

2009-03-22 Thread Paul Topping
romium- > d...@googlegroups.com] On Behalf Of Book'em Dano > Sent: Sunday, March 22, 2009 11:30 AM > To: Chromium-dev > Subject: [chromium-dev] Re: Quick question about struct initialization > > > Sorry if I wasn't clear enough, but that's actually what my question > i

[chromium-dev] Re: Quick question about struct initialization

2009-03-22 Thread Book'em Dano
Sorry if I wasn't clear enough, but that's actually what my question is. What's the need/point of calling memset if initialization via " = {0}; " works just as well. Are you saying that it doesn't? Or are you saying that you're not quite sure, and to be on the safe side, do both. I'd like to avoi

[chromium-dev] Re: Quick question about struct initialization

2009-03-22 Thread Smita
It works fine with gcc. However, you might want to initialize the entire array to 0 using a memset. Smita On Mar 21, 10:23 pm, "Book'em Dano" wrote: > Can someone please confirm whether it's safe to initialize a POD > struct using: > > MyStruct blat = {0}; > > with gcc on Linux/Mac? I know this