rfg@MCC.COM (Ron Guilmette) (01/23/89)
I thought that I would try something tricky and see if I could
redefine the sizeof operator. I ran the following code thru
G++ 1.32.0 and it got a segmentation violation in c++.
There are two issues here. First, it's obvious that the segmentation
violation shouldn't occur. Second, I think that allowing the sizeof
operator to be redefined would be a nice feature, and consistant
with the general philosophy of letting all operators be redefined.
What does cfront (1.2/2.0) do with this code?
class test {
public:
virtual operator sizeof();
};
// Ron Guilmette - MCC - Experimental (parallel) Systems Kit Project
// 3500 West Balcones Center Drive, Austin, TX 78759 - (512)338-3740
// ARPA: rfg@mcc.com
// UUCP: {ihnp4,seismo,ucb-vax,gatech}!cs.utexas.edu!pp!rfg
schmidt@siam.ics.uci.edu (Doug Schmidt) (01/24/89)
In article <8901222128.AA01734@riunite.aca.mcc.com> rfg@MCC.COM (Ron Guilmette) writes: [ g++ 1.32 give fatal signal for: ] > >class test { >public: > virtual operator sizeof(); >}; > Here is a quick patch for this problem: ---------------------------------------- *** cplus-decl.c.~1~ Sat Jan 21 20:36:43 1989 --- cplus-decl.c Mon Jan 23 16:27:39 1989 *************** *** 4407,4414 **** { if (virtualp) { ! error ("virtual non function declaration for field `%s'", ! IDENTIFIER_POINTER (declarator)); virtualp = 0; } } --- 4407,4417 ---- { if (virtualp) { ! if (declarator) ! error ("virtual non function declaration for field `%s'", ! IDENTIFIER_POINTER (declarator)); ! else ! error ("virtual non function declaration encountered"); virtualp = 0; } } ---------------------------------------- -- BBoard-ID: 616 BB-Posted: Sat, 21 Jan 89 23:59:19 PST Received: from [128.195.0.50] by ICS.UCI.EDU id am00547; 21 Jan 89 23:57 PST Received: from kl.sri.com by PARIS.ICS.UCI.EDU id aa17425; 21 Jan 89 0:28 PST