Why doesn't this work? (pointers)

R

Ron Natalie

Mike said:
The difference between our assertions is that you qualified
with 'POD' (and I used 'automatic' instead of 'default').

Yes, without the qualification of POD types, your statement
is wrong. The defect in the language is that automatic POD
types are not default initalized when other non-POD types
would be.
I think you're confusing me. What about such an object
initialized via an argument? (OR do you mean only those
declarations lacking an initializer?)

Default initialization, i.e., those without explicit initializers.
 
R

Ron Natalie

I was actually asking a genuine question, although I was pretty sure of
the answer. I get burned every now and then with "things in C++ what is
different than C". I didn't think there was a prohibition, and as I
recall some compilers do that in debug mode.

Right, there is no prohibition. The compiler is just not required
to initialize POD types in certain circumstances.

This whole initialization debacle, and the bandaids the standards
committee put on it with value initailziation is just odiferous slavish
following of the way things were always done in C. It causes more
problems than it solves, and if it were changed today, it would break
no code (although some people who rely on not using RAII might get a
little slower). If you want to skip default initialization, I think
that should be the explicit case.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,581
Members
45,057
Latest member
KetoBeezACVGummies

Latest Threads

Top