🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

cc1plus seg fault with illegal "switch"

#886
From: Bob Wilson
Date: Thu, 03 Sep 1992 01:48
33 lines
1170 bytes
version 2.2.2
configured with mips-dec-ultrix

There is a bug in cc1plus that causes it to segmentation fault when trying
to compile a switch expression that is a class without a conversion to int.
I know that's not legal C++ (apparently it was accepted by cfront1.2), but
it shouldn't crash the compiler.  The problem is in c_expand_start_case in
cp-typeck.c.  There needs to be a test for exp == 0 following the call to
build_type_conversion() (at line 6130).

If that's not good enough, here's a test case:

struct not_an_int {
    char *name;
};

main()
{
    not_an_int a, b, c;

    a.name = "a";
    b.name = "b";

    c = a;
    switch (c) {
	case a:
	    c.next = b;
	    break;
	case b:
	    c.next = a;
	    break;
    }
}
Technical Details
Message-ID: <9209030148.AA13521@life.ai.mit.edu>
Path: arc1-ca.pugleaf.net!sparky!uunet!cis.ohio-state.edu!shasta.stanford.edu!bwilson

Show Full Headers
Complete Article Headers
Newsgroups: gnu.g++.bug
Path: arc1-ca.pugleaf.net!sparky!uunet!cis.ohio-state.edu!shasta.stanford.edu!bwilson
From: bwilson@shasta.stanford.edu (Bob Wilson)
Subject: cc1plus seg fault with illegal "switch"
Message-ID: <9209030148.AA13521@life.ai.mit.edu>
Sender: gnulists@ai.mit.edu
Organization: GNUs Not Usenet
Distribution: gnu
Date: Thu, 3 Sep 1992 01:48:48 GMT
Approved: bug-g++@prep.ai.mit.edu
Lines: 34