allen@UXC.CSO.UIUC.EDU (Michael Allen) (08/01/89)
I wanted to overload the builtin hex function to take an unsigned argument, so I tried: ====================Cut Here for file tryhex.cc=========================== #include <stream.h> char* hex(unsigned ux, int width =0) { if ( long(ux) < 0 ) { if ( width ) return form(form("%d%%x",width),ux); else return form("%x",ux); } else return hex(long(ux)); } int main() { unsigned long z = 0xffffffff; // its signed value is -1 cout << "z = " << z << " decimal, " << hex(z) << " hex.\n"; return 0; } ====================Cut Here=========================== Results of 'g++ -c tryhex.cc' In function int main (): tryhex.cc:20: Segmentation violation g++: Program cc1plus got fatal signal 11. I also tried this with the -O flag and the -g flag, each gave the same error. Thanks, Michael Allen