rajarar@hubcap.clemson.edu (Bala Rajaraman) (01/05/90)
Could anyone please tell me what a fatal signal to cc1plus means? The context is as follows. The following programs were used to test accessing of local and global variables with the same name. I declared the global variable as a register variable (I know this is wrong, but just testing). The first program just declares the global variable ii as register and attempts to access its address. The compiler complains which is OK. In the second program the fatal signal to cc1plus arises. Why?? Program 1: tmp.cc -------------------------------------------------------------------- #include <stdio.h> #include <stream.h> register int ii; main() { cout << "Address of ii: " << long(&ii) << "\n"; } --------------------------------------------------------------------- g++ output: g++ -o tmp tmp.cc --------------------------------------------------------------------- tmp.cc:4: register name not specified for `ii' tmp.cc:4: global register variable follows a function definition In function int main (): tmp.cc:8: address of global register variable `ii' requested --------------------------------------------------------------------- Program 2: tmp2.cc --------------------------------------------------------------------- #include <stdio.h> #include <stream.h> int& incr(int&); register int ii = 20; main() { int ii; cout << "Address of ii: " << long(&ii) << "\n"; ii = 10; cout << "ii before: " << ii << "\n"; cout << "II before: " << ::ii << "\n"; incr(ii)++; cout << "ii before: " << ii << "\n"; cout << "II before: " << ::ii << "\n"; } int& incr(int& ii) { ii++; return ::ii; } --------------------------------------------------------------------- g++ output: g++ -o tmp2 tmp2.cc --------------------------------------------------------------------- tmp2.cc:5: register name not specified for `ii' tmp2.cc:5: global register variable has initial value tmp2.cc:5: global register variable follows a function definition g++: Program cc1plus got fatal signal 10. -------------------------------------------------------------------- The second program works ok when the global 'ii' is not declared register!! Thanks Bala :-) rajarar@hubcap.clemson.edu