🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

1 total messages Started by Michael Allen Mon, 31 Jul 1989 21:49
g++ version 1.35.0, sunos 4.0.3 on sun 4/260
#310
Author: Michael Allen
Date: Mon, 31 Jul 1989 21:49
39 lines
1309 bytes
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
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads