T.R | Title | User | Personal Name | Date | Lines |
---|
396.1 | | SMURF::PETERT | rigidly defined areas of doubt and uncertainty | Wed Jan 10 1996 11:57 | 18 |
396.2 | | UHUH::LUCIA | http://asaab.zko.dec.com/people/tjl/biography.html | Wed Jan 10 1996 13:49 | 6 |
396.3 | | DECC::CARLSON | | Thu Jan 11 1996 11:34 | 21 |
396.4 | More | TLE::LUCIA | http://asaab.zko.dec.com/~lucia/biography.html | Fri May 02 1997 11:41 | 35 |
| Opinions? Who wants a warning? Who doesn't? There appears to be a
problem in the way constants are used by the compiler and by the
debugger, i.e.
/local/lucia/scratch> ladebug const
Welcome to the Ladebug Debugger Version 4.0-35
------------------
object file name: const
Reading symbolic information ...done
(ladebug) list 1,100
1 #include <iostream.h>
2
3 int main()
4 {
5 const int four = 4;
6 cout << four << endl;
7 return four;
8 }
(ladebug) stop at 6
[#1: stop at "const.C":6 ]
(ladebug) run
[1] stopped at [int main(void):6 0x120001c98]
6 cout << four << endl;
(ladebug) whatis four
const int four
(ladebug) print four
4
(ladebug) a four=123 # change const int four to 123
(ladebug) print four # ladebug thinks four == 123
123
(ladebug) c # but the code doesn't.
4
Process has exited with status 4
(ladebug)
|
396.5 | | DECCXL::OUELLETTE | mudseason into blackfly season | Fri May 02 1997 13:23 | 9 |
| The compiler is justified in value propagation of const variables.
Sometimes you'll need to modify code in addition to data if you want
to fiddle this stuff in the debugger.
However, for things like const char[]'s and string literals, being
able to change them in the debugger might be useful & the compiler
is rather unlikely to value propagate them any time soon...
R.
|
396.6 | | TLE::LUCIA | http://asaab.zko.dec.com/~lucia/biography.html | Fri May 02 1997 13:46 | 12 |
| In the non -g case, I have no problem with the constant propagation. I
(of course being the debugger guy, I am biased towards debugging, and
being the compiler guy, you are biased towards compilation) would
really like to see "-g" mean "Compiler, do everything you can to assist
me in debugging my program". Which means turning off even the most
seemingly benign optimizations.
Perhaps in a case like this, the variable 'four' ought not be described
in the symbol table, since it clearly described incorrectly.
Tim
|
396.7 | | DECCXL::OUELLETTE | mudseason into blackfly season | Fri May 02 1997 14:35 | 4 |
| I'll make note of this and see if we cannot keep const variables
from being value propagated and folded at -O0 in the V6.0 compiler.
R.
|