Loop optimization
"Jérôme M. Berger"
jeberger at free.fr
Sun May 16 14:07:03 PDT 2010
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:jeberger at free.fr
http://jeberger.free.fr
Jabber: jeberger at jabber.fr
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 198 bytes
Desc: OpenPGP digital signature
URL: <http://lists.puremagic.com/pipermail/digitalmars-d-learn/attachments/20100516/08fa459b/attachment.pgp>
More information about the Digitalmars-d-learn
mailing list