|
|
|
|
|
by anyfoo
1352 days ago
|
|
This is "How to read variables optimized out in GDB sometimes", lest you might be misled to think that the value you are looking for is always hanging around somewhere. Sometimes, it's just gone, literally optimized out completely. Consider this piece of code: bool foo(void) {
int v = some_system_call();
bool b = v > 500;
some_function(b);
... /\* rest of code not using v \*/
}
There is no reason for the original value of v to stick around any longer than until the comparison with 500 has been made.Even though the syntactic scope of "int v" tells you that v is valid for the rest of the function body, and indeed it is while you are writing the source code, an optimizing compiler can and should make use of the fact that you are not actually using it anymore. |
|