[gnu.g++.bug] Problems with Gnu's own examples ???

T.Day@PURPLE.CS.UCL.AC.UK (Tim Day) (03/10/89)

I can't get the following to compile (or fail cleanly) under g++ version 1.32.0 
(is essentially the example from ``naming an expression's type'' in the
manual).
-------
#include <stream.h>

#define max(a,b) \
  ({typedef _ta = (a),_tb = (b); \
  _ta _a = (a);_tb _b = (b); \
  _a > _b ? _a : _b; })

main()
{	int a=1,b=2;
	cout << max(a,b);		// Here

	exit(0);
}
-------
Error is :
In function int main ():
ttest.cc:10: Segmentation violation
g++: Program c++ got fatal signal 11.

Also segmentation faults using a version based on 'typeof'.

Using
#define max(a,b) ((a)<(b)?(a):(b))
gives no problems

schmidt@beaver.ics.uci.edu (Doug Schmidt) (03/10/89)

In article <8903092200.AA05384@prep.ai.mit.edu> T.Day@PURPLE.CS.UCL.AC.UK (Tim Day) writes:
++ I can't get the following to compile (or fail cleanly) under g++ version 1.32.0 
++ (is essentially the example from ``naming an expression's type'' in the
++ manual).
++ -------
++ #include <stream.h>
++ 
++ #define max(a,b) \
++   ({typedef _ta = (a),_tb = (b); \
++   _ta _a = (a);_tb _b = (b); \
++   _a > _b ? _a : _b; })
++ 
++ main()
++ {	int a=1,b=2;
++ 	cout << max(a,b);		// Here
++ 
++ 	exit(0);
++ }

This bug should be fixed with 1.34.  It resulted from a typo in
cplus-parse.y.

Doug
--
schmidt@ics.uci.edu (ARPA) |   Per me si va nella citta' dolente.
office: (714) 856-4043     |   Per me si va nell'eterno dolore.
                           |   Per me si va tra la perduta gente.
                           |   Lasciate ogni speranza o voi ch'entrate.