C++ Logo


Advanced search

Re: [ub] Undefined behaviour from uninitialised variables

From: Tony Van Eerd <tvaneerd_at_[hidden]>
Date: Thu, 31 Oct 2013 17:41:11 +0000
> >
> > Had I a time machine, this would be my preference (not just missing
> members,
> > but all uninitialized variables). But I agree with Ville that this
> would
> > break backwards compatibility.
> >
> > On the other hand, maybe adding an attribute would help?
> Sorry, I should have been more clear.
> I was not suggesting that we remove the old notation, as you say that
> is impossible. However, with an attribute to denote "I really meant to
> leave this variable/member unitialised", compilers could more eagerly
> warn about uninitialised variables or members.

Yes, that's what I thought you were saying - so it wasn't entirely unclear :-)

ie (not really suggesting this syntax, just as an example)

int i; // old style. Uninitialized. Was this intentional?
int j = *; // new style - *purposely* uninitialized
int k = 3; // initialized.

Now compilers can more aggressively warn about 'i'.

And, in theory, we could even make it deprecated...

This transmission (including any attachments) may contain confidential information, privileged material (including material protected by the solicitor-client or other applicable privileges), or constitute non-public information. Any use of this information by anyone other than the intended recipient is prohibited. If you have received this transmission in error, please immediately reply to the sender and delete this information from your system. Use, dissemination, distribution, or reproduction of this transmission by unintended recipients is not authorized and may be unlawful.

Received on 2013-10-31 18:46:53