On Thu, 08 Dec 2011 13:17:44 -0500, so <[email protected]> wrote:
On Thu, 08 Dec 2011 19:25:10 +0200, Dejan Lekic <[email protected]>
wrote:
type a = a + 2; // compiles with no errors, no warnings, no explosions
(that i know of)
If "type" has the default initialiser, then what is the problem?
What does it do in both C and D context?
1. It does different things.
2. C version even worse because of debug/release difference.
3. If D still does this, it violates the B-D rule (either does the same
thing or doesn't compile at all. Actually there are many things violate
this rule...)
type a; // even this simple code violates B-D rule.
What is the use case?
. Is there any?
. If there is not any you think, but still compiler allows it, it
generates nothing but bugs (from experience :) ).
Question should be, why does it exist at all?
Actually, these statements don't violate the B-D rule. In C/C++ the value of
'a' prior to use is implementation defined (i.e. it is undefined by the spec)
and in practice tends to be some random stack value. D just sets that value to
a consistent default, which is completely compliant with the C spec.