div0 wrote:
> Jérôme M. Berger wrote:
>> div0 wrote:
>>> Jérôme M. Berger wrote:
>>>>    That depends. In C/C++, the default value for any global variable
>>>> is to have all bits set to 0 whatever that means for the actual data
>>>> type. 
>>> No it's not, it's always uninitialized.
>>>
>>      According to the C89 standard and onwards it *must* be initialized
>> to 0. If it isn't then your implementation isn't standard compliant
>> (needless to say, gcc, Visual, llvm, icc and dmc are all standard
>> compliant, so you won't have any difficulty checking).
> 
> Ah, I only do C++, where the standard is to not initialise.
> I didn't know the two specs had diverged like that.
> 
        The specs haven't diverged and C++ has mostly the same behaviour as
C where global variables are concerned. The only difference is that
if the global variable is a class with a constructor, then that
constructor gets called after the memory is zeroed out.

                Jerome
-- 
mailto:jeber...@free.fr
http://jeberger.free.fr
Jabber: jeber...@jabber.fr

Attachment: signature.asc
Description: OpenPGP digital signature

Reply via email to