🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: gnu.gcc.bug
Article #6037

exceptions and returning a struct (not a pointer or a reference)

#6037
From: Todd Brunhoff
Date: Tue, 07 Jan 1997 00:00
35 lines
1375 bytes
I'm using gcc/g++ 2.7.2

If a method is defined to return a struct, and throws an exception,
the catch clause somewhere above the caller will never be called,
and the code falls into the default exception handler.  Here is a
very simple program that fails:

#include "stdio.h"

struct S { int x; };

void doThrow(int i) {  throw i; }
 
S g() { doThrow(3); }

main()
{
  printf("...\n");
  try {
    g();
  } catch (...) {
    printf("xxx\n");
  }
}

Seems like it would affect lots of people.  Is this fixed in any planned
update.
---------------
internet: todd.brunhoff@tek.com
web:      http://www.cse.tek.com/~toddbru (inside Tek only)
US:       Todd Brunhoff; Tektronix; TV Test & Measurement;
          PO Box 500; MS 50-355; Beaverton, OR  97077-0001
Phone:    (503) 627-4911
Fax:      (503) 627-4486
Technical Details
Message-ID: <199701080212.SAA13338@jenzy.cse.tek.com>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 113d02,27ae56b25bf28f96,start
X-Google-Attributes: gid113d02,public
From: toddbru@mdhost.cse.tek.com (Todd Brunhoff)
Subject: exceptions and returning a struct (not a pointer or a reference)
Date: 1997/01/07
Message-ID: <199701080212.SAA13338@jenzy.cse.tek.com>
X-Deja-AN: 208387786
sender: bug-gcc-request@prep.ai.mit.edu
x-gateway: relay2.UU.NET from bug-gcc to gnu.gcc.bug; Tue, 7 Jan 1997 21:13:48 EST
reply-to: todd.brunhoff@tek.com
newsgroups: gnu.gcc.bug