We have a C++ program such as:
int&
Instance()
{
static int test;
return test;
}
int
main( int argc, char ** argv )
{
int& test = Instance();
printf("%d\n",test);
return 0;
}
Now I'm trying to print Instance::test, as suggested by some gdb documentation: https://ftp.gnu.org/old-gnu/Manuals/gdb/html_node/gdb_52.html
However, this yields:
(gdb) p Instance::test
No symbol "test" in specified context.
I'm compiling with -O0 -g.
printfthat knows nothing about what a reference is. It just seems wrong to me. I'll stick my neck out -- I don't have the C++ spec in front of me right now, but I'm hedging my bet that the code has undefined behavior due to passing a reference toprintf()The only issue that I could see is with the vararg implementationWhich was my point. Plus, comments are meant for comments, that's I didn't post my comment as an answer.