🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: gnu.g++.bug
Article #788

executable crash under g++/Sun

#788
From: Bradley D. Keister
Date: Wed, 26 Aug 1992 10:11
70 lines
1818 bytes
The following code crashes at runtime when built with g++/Sun.  It
runs without trouble under g++/DECstation and CC/DECstation.

#include <stdio.h>
#include <string.h>

// #include "strup.h"

void strup(char* string)
{
  for (; *string; string++)
    *string = ((*string >= 'a') && (*string <= 'z'))?
    *string-0x20: *string;
}
class A {
  
protected:
  int a;
  
public:
  A() {a=1;}
};

class B : public A {
  
protected:
  int b;
  
public:
  B() {b=1;}
};

A* choose_class(char* keyword)
{
  A* result;
  strup(keyword);
  if (strcmp(keyword, "CLASS_A") == 0)
    result = new A;
  if (strcmp(keyword, "CLASS_B") == 0)
    result = new B;
  
  return result;
}

main()
{
  A* Atest = choose_class("class_B");
  delete Atest;
  return 0;
}

Segmentation fault (core dumped)
cm5comp.psc.edu% dbx declare
Reading symbolic information...
Read 194 symbols
program terminated by signal SEGV (access to address exceeded protections)
(dbx) run
Running: declare 
signal SEGV (access to address exceeded protections) in strup__FPc at 0x22f8
strup__FPc+0x68:	stb    	%o1, [%o0]

Brad Keister
Department of Physics
Carnegie Mellon University
Pittsburgh, PA 15213
(412) 268-2772 (office)
(412) 681-0648 (FAX)

internet:	keister@poincare.phys.cmu.edu
BITNET:		keister%poincare.phys.cmu.edu@CARNEGIE
Technical Details
Message-ID: <9208261811.AA11644@poincare.phys.cmu.edu>
Path: arc1-ca.pugleaf.net!sparky!uunet!usc!cs.utexas.edu!zaphod.mps.ohio-state.edu!cis.ohio-state.edu!poincare.phys.cmu.edu!keister

Show Full Headers
Complete Article Headers
Newsgroups: gnu.g++.bug
Path: arc1-ca.pugleaf.net!sparky!uunet!usc!cs.utexas.edu!zaphod.mps.ohio-state.edu!cis.ohio-state.edu!poincare.phys.cmu.edu!keister
From: keister@poincare.phys.cmu.edu (Bradley D. Keister)
Subject: executable crash under g++/Sun
Message-ID: <9208261811.AA11644@poincare.phys.cmu.edu>
Sender: gnulists@ai.mit.edu
Organization: GNUs Not Usenet
Distribution: gnu
Date: Wed, 26 Aug 1992 10:11:38 GMT
Approved: bug-g++@prep.ai.mit.edu
Lines: 71