Title: | C++ |
Notice: | Read 1.* and use keywords (e.g. SHOW KEY/FULL KIT_CXX_VAX_VMS) |
Moderator: | DECCXX::AMARTIN |
Created: | Fri Nov 06 1987 |
Last Modified: | Thu Jun 05 1997 |
Last Successful Update: | Fri Jun 06 1997 |
Number of topics: | 3604 |
Total number of notes: | 18242 |
We've been moving from C to C++, and one of the things we miss is the ability to enable the CONTROLASSIGN warning, to catch bugs like this: if (i = 1) { when we meant if (i == 1) { We were surprised that this warning doesn't seem to be available in DECC++. Are there any plans to put it in? -Michael
T.R | Title | User | Personal Name | Date | Lines |
---|---|---|---|---|---|
3431.1 | Coding suggestion, fwiw... | DECC::SULLIVAN | Jeff Sullivan | Tue Feb 04 1997 18:02 | 15 |
Not sure if this will help, but, I've read this suggestion and heard it preached elsewhere... Write the conditional with the constant on the left of the "==" if (1 = i) { // this is not what you meant and will error instead of if (1 == i) { // this does what you meant I generally don't follow it myself, but it's not a bad idea. -Jeff | |||||
3431.2 | V6.0 will do something like this | DECCXX::MITCHELL | Tue Feb 04 1997 18:28 | 3 | |
cxx: Warning: test.cxx, line 3: possible use of "=" where "==" was intended if (i = 1) j = 1; ------------^ | |||||
3431.3 | Thanks! | GAAS::TSUK | Michael Tsuk | Wed Feb 05 1997 15:15 | 19 |
>Write the conditional with the constant on the left of the "==" > > if (1 = i) { // this is not what you meant and will error > >instead of > > if (1 == i) { // this does what you meant This works only if the thing on the left is a constant. We'd still have the problem if it were a variable. >V6.0 will do something like this >cxx: Warning: test.cxx, line 3: possible use of "=" where "==" was intended > if (i = 1) j = 1; >------------^ Thanks, this is just perfect. Now I just need to wait for V6.0... -Michael |