Thread overview | |||||||
---|---|---|---|---|---|---|---|
|
February 04, 2004 Compile error in assignment to bit field | ||||
---|---|---|---|---|
| ||||
const bit mySwitch = true; const bit[] mySwitches = [ true, false, false, true ]; int main() { mySwitch = false; // "test.d(6): '1' is not an lvalue" mySwitches[1] = true; // compiles ok return 0; } Same with v.77 and v.79 |
February 05, 2004 Re: Compile error in assignment to bit field | ||||
---|---|---|---|---|
| ||||
Posted in reply to larry cowan | larry cowan wrote:
> const bit[] mySwitches = [ true, false, false, true ]; mySwitches[1] = true; // compiles ok
Confirmed.
Moreover:
| mySwitches[4] = true; // also compiles ok
And:
| printf("%u\n", myswitches[4]);
compiles also, however gives bounds checking error at runtime.
|
February 08, 2004 Re: [bug] Compile error in assignment to bit field | ||||
---|---|---|---|---|
| ||||
Posted in reply to larry cowan | Note: I think there are 2 problems here: 1. The message "test.d(6): '1' is not an lvalue" is understandable (const mySwitch has already been equated to true = 1), but not very apropos. 2. Allowing me to change const mySwitches array entries shouldn't be allowed should it?, or do I have to "const" each entry somehow? HELP! "larry cowan" <larry_member@pathlink.com> modified his message news:bvs11e$1oc$1@digitaldaemon.com... > const bit mySwitch = true; > const bit[] mySwitches = [ true, false, false, true ]; > > int main() > { // mySwitch = false; // "test.d(6): '1' is not an lvalue", if compile attempted > mySwitches[1] = true; // compiles ok assert(mySwitches[1]); // succeeds > return 0; > } > > Same with v.77 and v.79 > > |
Copyright © 1999-2021 by the D Language Foundation