Error: constant false is not an lvalue

Jarrett Billingsley jarrett.billingsley at gmail.com
Sun Aug 30 07:30:31 PDT 2009


On Sun, Aug 30, 2009 at 7:13 AM, grauzone<none at example.net> wrote:
>> Although teeeeeeechnically speaking that would be illegal code. The D
>> spec says that it's not legal to use the value of uninitialized
>> variables. Default initialization is kind of a poor man's substitute
>> for actual flow control which determines that. By relying on default
>
> Am I the only one, who likes the current behaviour, and finds it annoying to
> be forced by the compiler to initialize all variables?

The default initialization in D certainly hasn't helped me catch any
bugs, only made them harder to spot. I'm a very big proponent of
catching things at compile time.

>> initialization, you're relying on what is actually nonconformant
>> behavior, and it could be broken in the future or by a smarter
>> compiler.
>
> How is this nonconformant? Initialization is guaranteed by D.

This is where the spec is unclear, since why bother having the "can't
access variables before assignment" rule if the "all variables are
default-initialized" rule all but removes the need for it?


More information about the Digitalmars-d-learn mailing list