home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #31 / NN_1992_31.iso / spool / gnu / g / bug / 2100 < prev    next >
Encoding:
Text File  |  1992-12-30  |  28.7 KB  |  1,416 lines

  1. Newsgroups: gnu.g++.bug
  2. Path: sparky!uunet!cis.ohio-state.edu!cs.rice.edu!dougm
  3. From: dougm@cs.rice.edu (Doug Moore)
  4. Subject: 2.3.3 - bad syntax in derived template constr arglist
  5. Message-ID: <9212300357.AA22048@cs.rice.edu>
  6. Sender: gnulists@ai.mit.edu
  7. Organization: GNUs Not Usenet
  8. Distribution: gnu
  9. Date: Wed, 30 Dec 1992 03:57:30 GMT
  10. Approved: bug-g++@prep.ai.mit.edu
  11. Lines: 1403
  12.  
  13. The code that appears at the end of this message uses templates and
  14. derivation and contains a syntax error; some combination of that
  15. creates an internal compiler error.
  16.  
  17. The architecture is sparc, sunos4.1.2.  The G++ is 2.3.3, as
  18. distributed.
  19.  
  20. The verbose compiler output is:
  21. ======================================================================
  22. g++ test.cc -v -Wall -lm
  23. Reading specs from /blossom/lib/gcc-lib/sun4/2.3.3/specs
  24. gcc version 2.3.3
  25.  /blossom/lib/gcc-lib/sun4/2.3.3/cpp -lang-c++ -v -undef -D__GNUC__=2 -D__GNUG__=2 -D__cplusplus -Dsparc -Dsun -Dunix -D__sparc__ -D__sun__ -D__unix__ -D__sparc -D__sun -D__unix -Wall test.cc /usr/tmp/cca22029.i
  26. GNU CPP version 2.3.3 (sparc)
  27.  /blossom/lib/gcc-lib/sun4/2.3.3/cc1plus /usr/tmp/cca22029.i -quiet -dumpbase test.cc -Wall -version -o /usr/tmp/cca22029.s
  28. GNU C++ version 2.3.3 (sparc) compiled by GNU C version 2.3.3.
  29. Tuple.h:85: syntax error before `{'
  30. Tuple.h:87: parse error at end of class template
  31. Tuple.h:87: Internal compiler error.
  32. Tuple.h:87: Please report this to `bug-g++@prep.ai.mit.edu'.
  33.  
  34. Compilation exited abnormally with code 1 at Tue Dec 29 21:53:07
  35. ======================================================================
  36.  
  37. The complete source follows.
  38.  
  39. Doug Moore
  40. (dougm@cs.rice.edu)
  41.  
  42. # 1 "test.cc"
  43. # 1 "Vector.h" 1
  44.  
  45.  
  46. # 1 "Tuple.h" 1
  47.  
  48.  
  49. # 1 "/blossom/lib/gcc-lib/sun4/2.3.3/g++-include/iostream.h" 1 3
  50.  
  51.  
  52.  
  53.  
  54.  
  55.  
  56.  
  57.  
  58.  
  59.  
  60.  
  61.  
  62.  
  63.  
  64.  
  65.  
  66.  
  67.  
  68.  
  69. #pragma interface
  70.  
  71.  
  72.  
  73. # 1 "/blossom/lib/gcc-lib/sun4/2.3.3/g++-include/streambuf.h" 1 3
  74.  
  75.  
  76.  
  77.  
  78.  
  79.  
  80.  
  81.  
  82.  
  83.  
  84.  
  85.  
  86.  
  87.  
  88.  
  89.  
  90.  
  91.  
  92.  
  93. #pragma interface
  94.  
  95.  
  96.    
  97.  
  98. # 1 "/blossom/lib/gcc-lib/sun4/2.3.3/g++-include/_G_config.h" 1 3
  99.   
  100.  
  101.  
  102.  
  103.  
  104.  
  105.  
  106. typedef long _G_clock_t;
  107. typedef short _G_dev_t;
  108. typedef long   _G_fpos_t;
  109. typedef unsigned short _G_gid_t;
  110. typedef unsigned long _G_ino_t;
  111. typedef unsigned short _G_mode_t;
  112. typedef short _G_nlink_t;
  113. typedef long _G_off_t;
  114. typedef int _G_pid_t;
  115. typedef int _G_ptrdiff_t;
  116. typedef int _G_sigset_t;
  117. typedef int _G_size_t;
  118. typedef long _G_time_t;
  119. typedef unsigned short _G_uid_t;
  120. typedef unsigned short _G_wchar_t;
  121. typedef int   _G_ssize_t;
  122. typedef char * _G_va_list;
  123.  
  124.  
  125.  
  126.  
  127.  
  128.  
  129.  
  130.  
  131.  
  132.  
  133.  
  134.  
  135.  
  136.  
  137.  
  138.  
  139.  
  140.  
  141.  
  142.  
  143.  
  144. # 25 "/blossom/lib/gcc-lib/sun4/2.3.3/g++-include/streambuf.h" 2 3
  145.  
  146.  
  147.  
  148.  
  149.  
  150.  
  151.  
  152.  
  153.  
  154.  
  155.  
  156.  
  157.  
  158.  
  159.  
  160. class ostream; class streambuf; class backupbuf;
  161.  
  162.  
  163.  
  164.  
  165.  
  166.  
  167.  
  168.  
  169.  
  170. extern "C" int __underflow(streambuf*);
  171. extern "C" int __overflow(streambuf*, int);
  172.  
  173. typedef _G_off_t streamoff;
  174. typedef _G_off_t streampos;  
  175.  
  176. typedef unsigned long __fmtflags;
  177. typedef unsigned char __iostate;
  178.  
  179. struct _ios_fields {  
  180.     streambuf *_strbuf;
  181.     ostream* _tie;
  182.     int _width;
  183.     __fmtflags _flags;
  184.     _G_wchar_t _fill;
  185.     __iostate _state;
  186.     __iostate _exceptions;
  187.     int _precision;
  188. };
  189.  
  190.  
  191.  
  192.  
  193.  
  194.  
  195.  
  196.  
  197.  
  198.  
  199.  
  200.  
  201.  
  202.  
  203.  
  204. # 95 "/blossom/lib/gcc-lib/sun4/2.3.3/g++-include/streambuf.h" 3
  205.  
  206.  
  207. class ios : public _ios_fields {
  208.   public:
  209.     typedef __fmtflags fmtflags;
  210.     typedef int iostate;
  211.     typedef int openmode;
  212.     enum io_state {
  213.     goodbit = 0 ,
  214.     eofbit = 1 ,
  215.     failbit = 2 ,
  216.     badbit = 4  };
  217.     enum open_mode {
  218.     in = 1 ,
  219.     out = 2 ,
  220.     ate = 4 ,
  221.     app = 8 ,
  222.     trunc = 16 ,
  223.     nocreate = 32 ,
  224.     noreplace = 64 ,
  225.     bin = 128  };
  226.     enum seek_dir { beg, cur, end};
  227.      
  228.     enum { skipws=01, left=02, right=04, internal=010,
  229.        dec=020, oct=040, hex=0100,
  230.        showbase=0200, showpoint=0400, uppercase=01000, showpos=02000,
  231.        scientific=04000, fixed=010000, unitbuf=020000, stdio=040000,
  232.        dont_close=0x80000000  
  233.        };
  234.     enum {  
  235.     basefield=dec+oct+hex,
  236.     floatfield = scientific+fixed,
  237.     adjustfield = left+right+internal
  238.     };
  239.  
  240. # 138 "/blossom/lib/gcc-lib/sun4/2.3.3/g++-include/streambuf.h" 3
  241.  
  242.  
  243.     ostream* tie() const { return _tie; }
  244.     ostream* tie(ostream* val) { ostream* save=_tie; _tie=val; return save; }
  245.  
  246.      
  247.     _G_wchar_t fill() const { return (_G_wchar_t)_fill; }
  248.     _G_wchar_t fill(_G_wchar_t newf)
  249.     {_G_wchar_t oldf = (_G_wchar_t)_fill; _fill = (char)newf; return oldf;}
  250.     fmtflags flags() const { return _flags; }
  251.     fmtflags flags(fmtflags new_val) {
  252.     fmtflags old_val = _flags; _flags = new_val; return old_val; }
  253.     int precision() const { return _precision; }
  254.     int precision(int newp) {
  255.     unsigned short oldp = _precision; _precision = (unsigned short)newp;
  256.     return oldp; }
  257.     fmtflags setf(fmtflags val) {
  258.     fmtflags oldbits = _flags;
  259.     _flags |= val; return oldbits; }
  260.     fmtflags setf(fmtflags val, fmtflags mask) {
  261.     fmtflags oldbits = _flags;
  262.     _flags = (_flags & ~mask) | (val & mask); return oldbits; }
  263.     fmtflags unsetf(fmtflags mask) {
  264.     fmtflags oldbits = _flags & mask;
  265.     _flags &= ~mask; return oldbits; }
  266.     int width() const { return _width; }
  267.     int width(int val) { int save = _width; _width = val; return save; }
  268.  
  269.  
  270.  
  271.  
  272.     void _throw_failure() { }
  273.  
  274.  
  275.     streambuf* rdbuf() const { return _strbuf; }
  276.     void clear(iostate state = 0) {
  277.     _state = _strbuf ? state : state|badbit;
  278.     if (_state & _exceptions) _throw_failure(); }
  279.     void set(iostate flag) { _state |= flag;
  280.     if (_state & _exceptions) _throw_failure(); }
  281.     int good() const { return _state == 0; }
  282.     int eof() const { return _state & ios::eofbit; }
  283.     int fail() const { return _state & (ios::badbit|ios::failbit); }
  284.     int bad() const { return _state & ios::badbit; }
  285.     iostate rdstate() const { return _state; }
  286.     operator void*() const { return fail() ? (void*)0 : (void*)(-1); }
  287.     int operator!() const { return fail(); }
  288.     iostate exception(iostate enable) {
  289.     iostate old = _exceptions; _exceptions = enable;
  290.     if (_state & _exceptions) _throw_failure();
  291.     return old; }
  292.  
  293.     static int sync_with_stdio(int on);
  294.     static void sync_with_stdio() { sync_with_stdio(1); }
  295.  
  296.  
  297.  
  298.  
  299.  
  300.  
  301.  
  302.  
  303.  
  304.   protected:
  305.     ios(streambuf* sb = 0, ostream* tie = 0);
  306.     virtual ~ios();
  307.     void init(streambuf* sb) { _state=0; _strbuf=sb; }
  308. };
  309.  
  310.  
  311.  
  312.  
  313. typedef ios::seek_dir _seek_dir;
  314.  
  315.  
  316.  
  317.  
  318.  
  319.  
  320.  
  321.  
  322.  
  323.  
  324.  
  325.  
  326.  
  327.  
  328.  
  329.  
  330.  
  331.  
  332.  
  333.  
  334.  
  335.  
  336.  
  337.  
  338.  
  339.  
  340.  
  341.  
  342.  
  343. class streammarker {
  344.     friend class streambuf;
  345.  
  346.  
  347.  
  348.     friend int __underflow(streambuf*);
  349.  
  350.     struct streammarker *_next;   
  351.     streambuf *_sbuf;  
  352.     streampos _spos;  
  353.     void set_streampos(streampos sp) { _spos = sp; }
  354.     void set_offset(int offset) { _pos = offset; _spos = (streampos)(-2); }
  355.      
  356.      
  357.     int _pos;
  358.   public:
  359.     streammarker(streambuf *sb);
  360.     ~streammarker();
  361.     int saving() { return  _spos == -2; }
  362.     int delta(streammarker&);
  363.     int delta();
  364. };
  365.  
  366. struct __streambuf {
  367.      
  368.     int _flags;         
  369.     char* _gptr;     
  370.     char* _egptr;     
  371.     char* _eback;     
  372.     char* _pbase;     
  373.     char* _pptr;     
  374.     char* _epptr;     
  375.     char* _base;     
  376.     char* _ebuf;     
  377.     struct streambuf *_chain;
  378.  
  379.      
  380.     friend class streammarker;
  381.     char *_other_gbase;  
  382.     char *_aux_limit;   
  383.     char *_other_egptr;  
  384.     streammarker *_markers;
  385.  
  386.  
  387.      
  388.     unsigned short _cur_column;
  389.     char _unused;
  390.     char _shortbuf[1];
  391. };
  392.  
  393. extern unsigned __adjust_column(unsigned start, const char *line, int count);
  394.  
  395. struct streambuf : private __streambuf {
  396.     friend class ios;
  397.     friend class istream;
  398.     friend class ostream;
  399.     friend class streammarker;
  400.  
  401.  
  402.  
  403.     friend int __underflow(streambuf*);
  404.  
  405.   protected:
  406.     static streambuf* _list_all;  
  407.     streambuf*& xchain() { return _chain; }
  408.     void _un_link();
  409.     void _link_in();
  410.     char* gptr() const { return _gptr; }
  411.     char* pptr() const { return _pptr; }
  412.     char* egptr() const { return _egptr; }
  413.     char* epptr() const { return _epptr; }
  414.     char* pbase() const { return _pbase; }
  415.     char* eback() const { return _eback; }
  416.     char* base() const { return _base; }
  417.     char* ebuf() const { return _ebuf; }
  418.     int blen() const { return _ebuf - _base; }
  419.     void xput_char(char c) { *_pptr++ = c; }
  420.     int xflags() { return _flags; }
  421.     int xflags(int f) { int fl = _flags; _flags = f; return fl; }
  422.     void xsetflags(int f) { _flags |= f; }
  423.     void xsetflags(int f, int mask) { _flags = (_flags & ~mask) | (f & mask); }
  424.     void gbump(int n) { _gptr += n; }
  425.     void pbump(int n) { _pptr += n; }
  426.     void setb(char* b, char* eb, int a=0);
  427.     void setp(char* p, char* ep) { _pbase=_pptr=p; _epptr=ep; }
  428.     void setg(char* eb, char* g, char *eg) { _eback=eb; _gptr=g; _egptr=eg; }
  429.     char *shortbuf() { return _shortbuf; }
  430.  
  431.     int in_backup() { return _flags & 0x100 ; }
  432.      
  433.     char *Gbase() { return in_backup() ? _other_gbase : _eback; }
  434.      
  435.     char *eGptr() { return in_backup() ? _other_egptr : _egptr; }
  436.      
  437.     char *Bbase() { return in_backup() ? _eback : _other_gbase; }
  438.     char *Bptr() { return _aux_limit; }
  439.      
  440.     char *eBptr() { return in_backup() ? _egptr : _other_egptr; }
  441.     char *Nbase() { return _other_gbase; }
  442.     char *eNptr() { return _other_egptr; }
  443.     int have_backup() { return _other_gbase != ((void*)0) ; }
  444.     int have_markers() { return _markers != ((void*)0) ; }
  445.     int _least_marker();
  446.     void switch_to_main_get_area();
  447.     void switch_to_backup_area();
  448.     void free_backup_area();
  449.     void unsave_markers();  
  450.     int put_mode() { return _flags & 0x800 ; }
  451.     int switch_to_get_mode();
  452.     
  453.     streambuf(int flags=0);
  454.   public:
  455.     static int flush_all();
  456.     static void flush_all_linebuffered();  
  457.     virtual int underflow() = 0;  
  458.     virtual int overflow(int c = (-1) ) = 0;  
  459.     virtual int doallocate();
  460.     virtual streampos seekoff(streamoff, _seek_dir, int mode=ios::in|ios::out);
  461.     virtual streampos seekpos(streampos pos, int mode = ios::in|ios::out);
  462.     int seekmark(streammarker& mark, int delta = 0);
  463.     int sputbackc(char c);
  464.     int sungetc();
  465.     virtual ~streambuf();
  466.     int unbuffered() { return _flags & 2  ? 1 : 0; }
  467.     int linebuffered() { return _flags & 0x200  ? 1 : 0; }
  468.     void unbuffered(int i)
  469.     { if (i) _flags |= 2 ; else _flags &= ~2 ; }
  470.     void linebuffered(int i)
  471.     { if (i) _flags |= 0x200 ; else _flags &= ~0x200 ; }
  472.     int allocate() {  
  473.     if (base() || unbuffered()) return 0;
  474.     else return doallocate(); }
  475.      
  476.     void allocbuf() { if (base() == ((void*)0) ) doallocbuf(); }
  477.     void doallocbuf();
  478.     virtual int sync();
  479.     virtual int pbackfail(int c);
  480.     virtual streambuf* setbuf(char* p, int len);
  481.     int in_avail() { return _egptr - _gptr; }
  482.     int out_waiting() { return _pptr - _pbase; }
  483.     virtual int xsputn(const char* s, int n);
  484.     int sputn(const char* s, int n) { return xsputn(s, n); }
  485.     int padn(char pad, int n);  
  486.     virtual int xsgetn(char* s, int n);
  487.     int sgetn(char* s, int n) { return xsgetn(s, n); }
  488.     int ignore(int);
  489.     virtual int get_column();
  490.     virtual int set_column(int);
  491.     long sgetline(char* buf, _G_size_t n, char delim, int putback_delim);
  492.     int sbumpc() {
  493.     if (_gptr >= _egptr && __underflow(this) == (-1) ) return (-1) ;
  494.     else return *(unsigned char*)_gptr++; }
  495.     int sgetc() {
  496.     if (_gptr >= _egptr && __underflow(this) == (-1) ) return (-1) ;
  497.     else return *(unsigned char*)_gptr; }
  498.     int snextc() {
  499.     if (_gptr >= _egptr && __underflow(this) == (-1) ) return (-1) ;
  500.     return _gptr++, sgetc(); }
  501.     int sputc(int c) {
  502.     if (_pptr >= _epptr) return __overflow(this, (unsigned char)c);
  503.     else return *_pptr++ = c, (unsigned char)c; }
  504.     void stossc() { if (_gptr < _egptr) _gptr++; }
  505.     int vscan(char const *fmt0, _G_va_list ap, ios* stream = ((void*)0) );
  506.     int scan(char const *fmt0 ...);
  507.     int vform(char const *fmt0, _G_va_list ap);
  508.     int form(char const *fmt0 ...);
  509.  
  510.  
  511.  
  512.  
  513. };
  514.  
  515.  
  516.  
  517.  
  518.  
  519.  
  520.  
  521.  
  522.  
  523. class backupbuf : public streambuf {
  524.     friend class streammarker;
  525.   protected:
  526.     backupbuf(int flags=0) : streambuf(flags|0x4000 ) { }
  527.   public:
  528.     virtual int pbackfail(int c);
  529.     virtual int underflow();
  530.     virtual int overflow(int c = (-1) );
  531. };
  532.  
  533. struct __file_fields {
  534.     short _fileno;
  535.     int _blksize;
  536.     _G_fpos_t  _offset;
  537.  
  538. };
  539.  
  540. class filebuf : public backupbuf {
  541.   protected:
  542.     struct __file_fields _fb;
  543.     void init();
  544.   public:
  545.     static const int openprot;  
  546.     filebuf();
  547.     filebuf(int fd);
  548.     filebuf(int fd, char* p, int len);
  549.     ~filebuf();
  550.     filebuf* attach(int fd);
  551.     filebuf* open(const char *filename, const char *mode);
  552.     filebuf* open(const char *filename, ios::openmode mode, int prot = 0664);
  553.     virtual int underflow();
  554.     virtual int overflow(int c = (-1) );
  555.     int is_open() const { return _fb._fileno >= 0; }
  556.     int fd() const { return is_open() ? _fb._fileno : (-1) ; }
  557.     filebuf* close();
  558.     virtual int doallocate();
  559.     virtual streampos seekoff(streamoff, _seek_dir, int mode=ios::in|ios::out);
  560.     virtual streambuf* setbuf(char* p, int len);
  561.     int xsputn(const char* s, int n);
  562.     int xsgetn(char* s, int n);
  563.     virtual int sync();
  564.   protected:  
  565.  
  566.     int is_reading() { return eback() != egptr(); }
  567.     char* cur_ptr() { return is_reading() ?  gptr() : pptr(); }
  568.      
  569.     char* file_ptr() { return eGptr(); }
  570.     int do_write(const char *data, int to_do);
  571.     int do_flush() { return do_write(_pbase, _pptr-_pbase); }
  572.      
  573.     virtual _G_ssize_t sys_read(char* buf, _G_size_t size);
  574.     virtual _G_fpos_t  sys_seek(_G_fpos_t , _seek_dir);
  575.     virtual _G_ssize_t sys_write(const void*, long);
  576.     virtual int sys_stat(void*);  
  577.     virtual int sys_close();
  578. };
  579.  
  580. inline ios::ios(streambuf* sb  , ostream* tie  ) {
  581.         _state = sb ? ios::goodbit : ios::badbit; _exceptions=0;
  582.         _strbuf=sb; _tie = tie; _width=0; _fill=' ';
  583.         _flags=ios::skipws|ios::dec; _precision=6; }
  584. inline ios::~ios() {
  585.     if (!(_flags & (unsigned int)ios::dont_close)) delete _strbuf; }
  586.  
  587.  
  588. # 24 "/blossom/lib/gcc-lib/sun4/2.3.3/g++-include/iostream.h" 2 3
  589.  
  590.  
  591. class istream; class ostream;
  592. typedef ios& (*__manip)(ios&);
  593. typedef istream& (*__imanip)(istream&);
  594. typedef ostream& (*__omanip)(ostream&);
  595.  
  596. extern istream& ws(istream& ins);
  597. extern ostream& flush(ostream& outs);
  598. extern ostream& endl(ostream& outs);
  599. extern ostream& ends(ostream& outs);
  600.  
  601. class ostream : virtual public ios
  602. {
  603.      
  604.     void do_osfx();
  605.   public:
  606.     ostream() { }
  607.     ostream(streambuf* sb, ostream* tied=((void*)0) );
  608.     int opfx() {
  609.     if (!good()) return 0; else { if (_tie) _tie->flush(); return 1;} }
  610.     void osfx() { if (flags() & (ios::unitbuf|ios::stdio))
  611.               do_osfx(); }
  612.     streambuf* ostreambuf() const { return _strbuf; }
  613.     ostream& flush();
  614.     ostream& put(char c) { _strbuf->sputc(c); return *this; }
  615.     ostream& put(unsigned char c) { return put((char)c); }
  616.  
  617.     ostream& write(const char *s, int n);
  618.     ostream& write(const unsigned char *s, int n) { return write((const char*)s, n);}
  619.  
  620.     ostream& put(signed char c) { return put((char)c); }
  621.     ostream& write(const signed char *s, int n) { return write((const char*)s, n);}
  622.  
  623.     ostream& write(const void *s, int n) { return write((const char*)s, n);}
  624.     ostream& seekp(streampos);
  625.     ostream& seekp(streamoff, _seek_dir);
  626.     streampos tellp();
  627.     ostream& form(const char *format ...);
  628.     ostream& vform(const char *format, _G_va_list args);
  629.  
  630.     ostream& operator<<(char c);
  631.     ostream& operator<<(unsigned char c) { return (*this) << (char)c; }
  632.  
  633.     ostream& operator<<(signed char c) { return (*this) << (char)c; }
  634.  
  635.     ostream& operator<<(const char *s);
  636.     ostream& operator<<(const unsigned char *s)
  637.     { return (*this) << (const char*)s; }
  638.  
  639.     ostream& operator<<(const signed char *s)
  640.     { return (*this) << (const char*)s; }
  641.  
  642.     ostream& operator<<(void *p);
  643.     ostream& operator<<(int n);
  644.     ostream& operator<<(unsigned int n);
  645.     ostream& operator<<(long n);
  646.     ostream& operator<<(unsigned long n);
  647.  
  648.     ostream& operator<<(long long n);
  649.     ostream& operator<<(unsigned long long n);
  650.  
  651.     ostream& operator<<(short n) {return operator<<((int)n);}
  652.     ostream& operator<<(unsigned short n) {return operator<<((unsigned int)n);}
  653.     ostream& operator<<(double n);
  654.     ostream& operator<<(float n) { return operator<<((double)n); }
  655.     ostream& operator<<(__omanip func) { return (*func)(*this); }
  656.     ostream& operator<<(__manip func) {(*func)(*this); return *this;}
  657.     ostream& operator<<(streambuf*);
  658. };
  659.  
  660. class istream : virtual public ios
  661. {
  662.      
  663.     _G_ssize_t _gcount;
  664.  
  665.     int _skip_ws();
  666.   public:
  667.     istream() { _gcount = 0; }
  668.     istream(streambuf* sb, ostream*tied=((void*)0) );
  669.     streambuf* istreambuf() const { return _strbuf; }
  670.     istream& get(char* ptr, int len, char delim = '\n');
  671.     istream& get(unsigned char* ptr, int len, char delim = '\n')
  672.     { return get((char*)ptr, len, delim); }
  673.     istream& get(char& c);
  674.     istream& get(unsigned char& c) { return get((char&)c); }
  675.     istream& getline(char* ptr, int len, char delim = '\n');
  676.     istream& getline(unsigned char* ptr, int len, char delim = '\n')
  677.     { return getline((char*)ptr, len, delim); }
  678.  
  679.     istream& get(signed char& c)  { return get((char&)c); }
  680.     istream& get(signed char* ptr, int len, char delim = '\n')
  681.     { return get((char*)ptr, len, delim); }
  682.     istream& getline(signed char* ptr, int len, char delim = '\n')
  683.     { return getline((char*)ptr, len, delim); }
  684.  
  685.     istream& read(char *ptr, int n);
  686.     istream& read(unsigned char *ptr, int n) { return read((char*)ptr, n); }
  687.  
  688.     istream& read(signed char *ptr, int n) { return read((char*)ptr, n); }
  689.  
  690.     istream& read(void *ptr, int n) { return read((char*)ptr, n); }
  691.      
  692.     istream& get(streambuf& sb, char delim = '\n');
  693.     istream& gets(char **s, char delim = '\n');
  694.     int ipfx(int need) {
  695.     if (!good()) { set(ios::failbit); return 0; }
  696.     if (_tie && (need == 0 || rdbuf()->in_avail() < need)) _tie->flush();
  697.     if (!need && (flags() & ios::skipws)) return _skip_ws();
  698.     return 1;
  699.     }
  700.     int ipfx0() {  
  701.     if (!good()) { set(ios::failbit); return 0; }
  702.     if (_tie) _tie->flush();
  703.     if (flags() & ios::skipws) return _skip_ws();
  704.     return 1;
  705.     }
  706.     int ipfx1() {  
  707.     if (!good()) { set(ios::failbit); return 0; }
  708.     if (_tie && rdbuf()->in_avail() == 0) _tie->flush();
  709.     return 1;
  710.     }
  711.     int get() { if (!ipfx1()) return (-1) ;
  712.         int ch = _strbuf->sbumpc();
  713.         if (ch == (-1) ) set(ios::eofbit);
  714.         return ch; }
  715.     int peek() { if (!ipfx1()) return (-1) ;
  716.         int ch = _strbuf->sgetc();
  717.         if (ch == (-1) ) set(ios::eofbit);
  718.         return ch; }
  719.     _G_ssize_t gcount() { return _gcount; }
  720.     istream& ignore(int n=1, int delim = (-1) );
  721.     istream& seekg(streampos);
  722.     istream& seekg(streamoff, _seek_dir);
  723.     streampos tellg();
  724.     istream& putback(char ch) {
  725.     if (good() && _strbuf->sputbackc(ch) == (-1) ) clear(ios::badbit);
  726.     return *this;}
  727.     istream& unget() {
  728.     if (good() && _strbuf->sungetc() == (-1) ) clear(ios::badbit);
  729.     return *this;}
  730.     istream& scan(const char *format ...);
  731.     istream& vscan(const char *format, _G_va_list args);
  732.  
  733.  
  734.  
  735.  
  736.  
  737.     istream& operator>>(char*);
  738.     istream& operator>>(unsigned char* p) { return operator>>((char*)p); }
  739.  
  740.     istream& operator>>(signed char*p) { return operator>>((char*)p); }
  741.  
  742.     istream& operator>>(char& c);
  743.     istream& operator>>(unsigned char& c) {return operator>>((char&)c);}
  744.  
  745.     istream& operator>>(signed char& c) {return operator>>((char&)c);}
  746.  
  747.     istream& operator>>(int&);
  748.     istream& operator>>(long&);
  749.  
  750.     istream& operator>>(long long&);
  751.  
  752.     istream& operator>>(short&);
  753.     istream& operator>>(unsigned int&);
  754.     istream& operator>>(unsigned long&);
  755.  
  756.     istream& operator>>(unsigned long long&);
  757.  
  758.     istream& operator>>(unsigned short&);
  759.     istream& operator>>(float&);
  760.     istream& operator>>(double&);
  761.     istream& operator>>( __manip func) {(*func)(*this); return *this;}
  762.     istream& operator>>(__imanip func) { return (*func)(*this); }
  763.     istream& operator>>(streambuf*);
  764. };
  765.  
  766.  
  767. class iostream : public istream, public ostream
  768. {
  769.     _G_ssize_t _gcount;
  770.   public:
  771.     iostream() { _gcount = 0; }
  772.     iostream(streambuf* sb, ostream*tied=((void*)0) );
  773. };
  774.  
  775. extern istream cin;
  776. extern ostream cout, cerr, clog;  
  777.  
  778. struct Iostream_init { } ;   
  779.  
  780. inline ios& dec(ios& i)
  781. { i.setf(ios::dec, ios::dec|ios::hex|ios::oct); return i; }
  782. inline ios& hex(ios& i)
  783. { i.setf(ios::hex, ios::dec|ios::hex|ios::oct); return i; }
  784. inline ios& oct(ios& i)
  785. { i.setf(ios::oct, ios::dec|ios::hex|ios::oct); return i; }
  786.  
  787.  
  788. # 3 "Tuple.h" 2
  789.  
  790.  
  791.  
  792.  
  793.  
  794.  
  795.  
  796.  
  797.  
  798.  
  799. template<class Scalar>    inline void tuple_set(Scalar dst[], const Scalar src, int size)    {    do dst[--size]  = src;    while (size > 0);    } ;
  800.  
  801.  
  802.  
  803.  
  804.  
  805.  
  806.  
  807.  
  808.  
  809. template<class Scalar>    inline void tuple_copy(Scalar dst[], const Scalar src[], int size)    {    do --size, dst[size]  = src[size];    while (size > 0);    } ;
  810.  
  811.  
  812.  
  813.  
  814.  
  815.  
  816.  
  817.  
  818.  
  819.  
  820.  
  821.  
  822.  
  823.  
  824.  
  825.  
  826.  
  827. template<class Scalar>
  828. inline istream& tuple_scan(istream& in, Scalar elem[], int size)                  
  829. {
  830.   int i = 0;
  831.   do --size, in >> elem[i++];
  832.   while (size > 0);
  833.   return in;
  834. }
  835.  
  836. template<class Scalar>
  837. inline ostream& tuple_print(ostream& ut, Scalar elem[], int size)
  838. {
  839.   int i = 0;
  840.   do --size, ut << " " << elem[i++];
  841.   while (size > 0);
  842.   return ut;
  843. }
  844.  
  845. template <class Scalar, int size>
  846. class Tuple
  847. {
  848. public:
  849.   
  850.   Tuple(Scalar s = 0) {tuple_set(elem, s, size);}
  851.   Tuple(Scalar values[size]) {tuple_copy(elem, values, size);}
  852.   Tuple(const Tuple& src) {tuple_copy(elem, src.elem, size);}
  853.   Tuple(istream& in) {scan(in);}
  854.   
  855.   Tuple& operator = (const Tuple& src)
  856.   {tuple_copy(elem, src.elem, size); return *this;}
  857.  
  858.   Scalar& operator[] (int i) {return elem[i];}
  859.  
  860.   Scalar operator[] (int i) const {return elem[i];}
  861.   
  862. friend istream& operator >> (istream& in, Tuple<Scalar,size>& dst)
  863.   {return dst.scan(in);}
  864.   
  865. friend ostream& operator << (ostream& ut, const Tuple<Scalar,size>& src)
  866.   {return src.print(ut);}
  867.  
  868. protected:
  869.   Scalar elem[size];
  870.   enum Uninitialized {NO_INIT};
  871.   Tuple(NO_INIT) {}
  872.  
  873.   istream& scan(istream& in) {return tuple_scan(in, elem, size);}
  874.   
  875.   ostream& print(ostream& ut) const {return tuple_print(ut, elem, size);}
  876. };
  877.  
  878. template <class Scalar, int size>
  879. inline istream& operator >> (istream& in, Tuple<Scalar,size>& dst)
  880. {return dst.scan(in);}
  881.  
  882. template <class Scalar, int size>
  883. inline ostream& operator << (ostream& ut, const Tuple<Scalar,size>& src)
  884. {return src.print(ut);}
  885.  
  886.  
  887. # 3 "Vector.h" 2
  888.  
  889. # 1 "/blossom/lib/gcc-lib/sun4/2.3.3/g++-include/iostream.h" 1 3
  890.  
  891.  
  892.  
  893.  
  894.  
  895.  
  896.  
  897.  
  898.  
  899.  
  900.  
  901.  
  902.  
  903.  
  904.  
  905.  
  906.  
  907. # 222 "/blossom/lib/gcc-lib/sun4/2.3.3/g++-include/iostream.h" 3
  908.  
  909. # 4 "Vector.h" 2
  910.  
  911. # 1 "/blossom/lib/gcc-lib/sun4/2.3.3/g++-include/math.h" 1 3
  912.  
  913.  
  914.  
  915.  
  916.  
  917.  
  918.  
  919.  
  920.  
  921.  
  922.  
  923.  
  924.  
  925.  
  926.  
  927.  
  928.  
  929.  
  930.  
  931.  
  932.  
  933. #pragma interface
  934.  
  935.  
  936.  
  937.  
  938.  
  939.  
  940.  
  941.  
  942.  
  943.  
  944.  
  945. # 64 "/blossom/lib/gcc-lib/sun4/2.3.3/g++-include/math.h" 3
  946.  
  947. extern "C" {
  948.  
  949. double  acos(double);
  950. double  acosh(double);
  951. double  asin(double);
  952. double  asinh(double);
  953. double  atan(double);
  954. double  atan2(double, double);
  955. double  atanh(double);
  956. double  cbrt(double);
  957. double  ceil(double);
  958. double  copysign(double,double);
  959. double  cos(double);
  960. double  cosh(double);
  961. double  drem(double,double);
  962. double  erf(double);
  963. double  erfc(double);
  964. double  exp(double);
  965. double  expm1(double);
  966. double  fabs(double);
  967. double  finite(double);
  968. double  floor(double);
  969. double    fmod(double, double);
  970. double  frexp(double, int*);
  971. double  gamma(double);
  972. double  hypot(double,double);
  973. double  infnan(int);
  974.  
  975.  
  976. int     isinf(double);
  977. int     isnan(double);
  978.  
  979. double  j0(double);
  980. double  j1(double);
  981. double  jn(int, double);
  982. double  ldexp(double, int);
  983. double  lgamma(double);
  984. double  log(double);
  985. double  log10(double);
  986. double  log1p(double);
  987. double  logb(double);
  988. double  modf(double, double*);
  989. double  pow(double, double);
  990. double  rint(double);
  991. double  scalb(double, int);
  992. double  sin(double);
  993. double  sinh(double);
  994. double  sqrt(double);
  995. double  tan(double);
  996. double  tanh(double);
  997. double  y0(double);
  998. double  y1(double);
  999. double  yn(int, double);
  1000.  
  1001. double aint(double);
  1002. double anint(double);
  1003. int irint(double);
  1004. int nint(double);
  1005. }
  1006.  
  1007.  
  1008.  
  1009.  
  1010.  
  1011.  
  1012.  
  1013.  
  1014. struct libm_exception
  1015. {
  1016.   int type;
  1017.   char* name;
  1018.   double arg1, arg2, retval;
  1019. };
  1020.  
  1021.  
  1022.  
  1023.  
  1024.  
  1025.  
  1026.  
  1027.  
  1028. extern "C" int matherr(libm_exception*);
  1029.  
  1030.  
  1031.  
  1032. # 1 "/blossom/lib/gcc-lib/sun4/2.3.3/include/float.h" 1 3
  1033.  
  1034.  
  1035.  
  1036.  
  1037.  
  1038.     
  1039.  
  1040.  
  1041.     
  1042.  
  1043.  
  1044.     
  1045.  
  1046.  
  1047.     
  1048.  
  1049.  
  1050.     
  1051.  
  1052.  
  1053.     
  1054.  
  1055.  
  1056.     
  1057.  
  1058.  
  1059.     
  1060.  
  1061.  
  1062.     
  1063.  
  1064.  
  1065.     
  1066.  
  1067.  
  1068.     
  1069.  
  1070.  
  1071.  
  1072.     
  1073.  
  1074.  
  1075.     
  1076.  
  1077.  
  1078.     
  1079.  
  1080.  
  1081.     
  1082.  
  1083.  
  1084.     
  1085.  
  1086.  
  1087.     
  1088.  
  1089.  
  1090.     
  1091.  
  1092.  
  1093.     
  1094.  
  1095.  
  1096.     
  1097.  
  1098.  
  1099.  
  1100.     
  1101.  
  1102.  
  1103.     
  1104.  
  1105.  
  1106.     
  1107.  
  1108.  
  1109.  
  1110. union __convert_long_double {
  1111.   int __convert_long_double_i[4];
  1112.   long double __convert_long_double_d;
  1113. };
  1114.  
  1115.  
  1116.     
  1117.  
  1118.  
  1119.     
  1120.  
  1121.  
  1122.     
  1123.  
  1124.  
  1125.     
  1126.  
  1127.  
  1128.     
  1129.  
  1130.  
  1131.     
  1132.  
  1133.  
  1134.  
  1135.  
  1136. # 150 "/blossom/lib/gcc-lib/sun4/2.3.3/g++-include/math.h" 2 3
  1137.  
  1138.  
  1139.  
  1140.  
  1141.  
  1142.  
  1143.  
  1144.  
  1145.  
  1146.  
  1147.  
  1148.  
  1149.  
  1150.  
  1151.  
  1152.  
  1153.  
  1154.  
  1155.  
  1156.  
  1157.  
  1158.  
  1159.  
  1160.  
  1161.  
  1162.  
  1163.  
  1164.  
  1165.  
  1166.  
  1167.  
  1168.  
  1169.  
  1170.  
  1171.  
  1172.  
  1173.  
  1174.  
  1175.  
  1176.  
  1177.  
  1178.  
  1179.  
  1180.  
  1181.  
  1182.  
  1183.  
  1184.  
  1185.  
  1186.  
  1187.  
  1188.  
  1189.  
  1190.  
  1191.  
  1192.  
  1193.  
  1194.  
  1195.  
  1196.  
  1197.  
  1198.  
  1199.  
  1200.  
  1201.  
  1202.  
  1203.  
  1204.  
  1205.  
  1206.  
  1207. # 5 "Vector.h" 2
  1208.  
  1209.  
  1210. template <class Scalar, int size>
  1211. class Vector: public Tuple<Scalar, size>
  1212. {
  1213. public:
  1214.   
  1215. friend Vector operator+ (const Vector& src1, const Vector& src2);
  1216.   Vector& operator+= (const Vector& src);
  1217.   Vector operator- (const Vector& src) const;
  1218.   Vector& operator-= (const Vector& src);
  1219.   Vector operator- () const;
  1220. friend Vector operator* (const Vector& src1, Scalar src2);
  1221.   Vector& operator*= (Scalar s);
  1222. friend Vector operator/ (const Vector& src1, Scalar src2);
  1223.   Vector& operator/= (Scalar s);
  1224. friend Scalar operator* (const Vector& src1, const Vector& src2);
  1225.  
  1226.   Scalar length2() const;
  1227.   Scalar length() const;
  1228.   Vector unit() const;
  1229.   Vector& unitize();
  1230.  
  1231. friend istream& operator >> (istream& in, Vector<Scalar,size>& dst);
  1232. friend ostream& operator << (ostream& ut, const Vector<Scalar,size>& src);
  1233. };
  1234.  
  1235. template<class Scalar>    void vectr_add(Scalar dst[], const Scalar src1[], const Scalar src2[], int size) {    do --size, dst[size] = src1[size]  + src2[size];    while (size > 0);    } ;
  1236.  
  1237. template <class Scalar, int size>
  1238. inline Vector<Scalar,size>
  1239. operator+ (const Vector<Scalar,size>& src1, const Vector<Scalar,size>& src2)
  1240. {
  1241.   Vector<Scalar,size> dst;
  1242.   vectr_add(dst.elem, src1.elem, src2.elem, size);
  1243.   return dst;
  1244. }
  1245.  
  1246. template<class Scalar>    inline void vectr_addcopy(Scalar dst[], const Scalar src[], int size)    {    do --size, dst[size]  += src[size];    while (size > 0);    } ;
  1247.  
  1248. template <class Scalar, int size>
  1249. inline Vector<Scalar,size>&
  1250. Vector<Scalar,size>::operator+= (const Vector& src)
  1251. {
  1252.   vectr_addcopy(elem, src.elem, size);
  1253.   return *this;
  1254. }
  1255.  
  1256. template<class Scalar>    void vectr_sub(Scalar dst[], const Scalar src1[], const Scalar src2[], int size) {    do --size, dst[size] = src1[size]  - src2[size];    while (size > 0);    } ;
  1257.  
  1258. template <class Scalar, int size>
  1259. inline Vector<Scalar,size>
  1260. Vector<Scalar,size>::operator- (const Vector& src) const
  1261. {
  1262.   Vector dst(Tuple::NO_INIT);
  1263.   vectr_sub(dst.elem, elem, src.elem, size);
  1264.   return dst;
  1265. }
  1266.  
  1267. template<class Scalar>    inline void vectr_subcopy(Scalar dst[], const Scalar src[], int size)    {    do --size, dst[size]  -= src[size];    while (size > 0);    } ;
  1268.  
  1269. template <class Scalar, int size>
  1270. inline Vector<Scalar,size>&
  1271. Vector<Scalar,size>::operator-= (const Vector& src)
  1272. {
  1273.   vectr_subcopy(elem, src.elem, size);
  1274.   return *this;
  1275. }
  1276.  
  1277. template <class Scalar, int size>
  1278. inline Vector<Scalar, size>
  1279. Vector<Scalar,size>::operator- () const
  1280. {
  1281.   Vector dst(Tuple::NO_INIT);
  1282.   drctn_negcopy(dst.elem, elem, size);
  1283.   return dst;
  1284. }
  1285.  
  1286. template<class Scalar>    void vectr_smulcopy(Scalar dst[], const Scalar src1[], Scalar src2, int size)    {    do --size, dst[size] = src1[size]  * src2;    while (size > 0);    } ;
  1287.  
  1288. template <class Scalar, int size>
  1289. inline Vector<Scalar,size>
  1290. operator* (const Vector<Scalar,size>& src, Scalar s)
  1291. {
  1292.   Vector<Scalar,size> dst(Tuple::NO_INIT);
  1293.   vectr_smulcopy(dst.elem, src.elem, s, size);
  1294.   return dst;
  1295. }
  1296.  
  1297. template<class Scalar>    inline void vectr_mpycopy(Scalar dst[], const Scalar src, int size)    {    do dst[--size]  *= src;    while (size > 0);    } ;
  1298.  
  1299. template <class Scalar, int size>
  1300. inline Vector<Scalar,size>&
  1301. Vector<Scalar,size>::operator*= (Scalar s)
  1302. {
  1303.   vectr_mpycopy(elem, s, size);
  1304.   return *this;
  1305. }
  1306.  
  1307. template <class Scalar, int size>
  1308. inline Vector<Scalar,size>
  1309. operator/ (const Vector<Scalar,size>& src, Scalar s)
  1310. {
  1311.   Vector<Scalar,size> dst(Tuple::NO_INIT);
  1312.   vectr_smulcopy(dst.elem, src.elem, 1./s, size);
  1313.   return dst;
  1314. }
  1315.  
  1316. template <class Scalar, int size>
  1317. inline Vector<Scalar,size>&
  1318. Vector<Scalar,size>::operator/= (Scalar s)
  1319. {
  1320.   vectr_mpycopy(elem, 1./s, size);
  1321.   return *this;
  1322. }
  1323.  
  1324. template <class Scalar, int size>
  1325. inline Vector<Scalar,size>
  1326. operator* (Scalar s, const Vector<Scalar,size>& src)
  1327. {return src * s;}
  1328.  
  1329. template <class Scalar, int size>
  1330. inline Scalar
  1331. operator* (const Vector<Scalar,size>& src1, const Vector<Scalar,size>& src2)
  1332. {
  1333.   Scalar dot = 0;
  1334.   int sz = size;
  1335.   do --sz, dot += src1.elem[sz] * src2.elem[sz];
  1336.   while (sz > 0);
  1337.   return dot;
  1338. }
  1339.  
  1340. template <class Scalar, int size>
  1341. inline Scalar
  1342. Vector<Scalar,size>::length2() const
  1343. {
  1344.   return *this * *this;
  1345. }
  1346.  
  1347. template <class Scalar, int size>
  1348. inline Scalar
  1349. Vector<Scalar,size>::length() const
  1350. {
  1351.   return sqrt(length2());
  1352. }
  1353.  
  1354. template <class Scalar, int size>
  1355. inline Vector<Scalar,size>
  1356. Vector<Scalar,size>::unit() const
  1357. {
  1358.   Scalar l = length();
  1359.   return (l!=0)? *this / l: *this;
  1360. }
  1361.  
  1362. template <class Scalar, int size>
  1363. inline Vector<Scalar,size>&
  1364. Vector<Scalar,size>::unitize()
  1365. {
  1366.   Scalar l = length();
  1367.   return (l!=0)? *this /= l: *this;
  1368. }
  1369.  
  1370. template <class Scalar, int size>
  1371. inline istream& operator >> (istream& in, Vector<Scalar,size>& dst)
  1372. {return dst.scan(in);}
  1373.  
  1374. template <class Scalar, int size>
  1375. inline ostream& operator << (ostream& ut, const Vector<Scalar,size>& src)
  1376. {return src.print(ut);}
  1377.  
  1378.  
  1379. # 1 "test.cc" 2
  1380.  
  1381. # 1 "/blossom/lib/gcc-lib/sun4/2.3.3/g++-include/iostream.h" 1 3
  1382.  
  1383.  
  1384.  
  1385.  
  1386.  
  1387.  
  1388.  
  1389.  
  1390.  
  1391.  
  1392.  
  1393.  
  1394.  
  1395.  
  1396.  
  1397.  
  1398.  
  1399. # 222 "/blossom/lib/gcc-lib/sun4/2.3.3/g++-include/iostream.h" 3
  1400.  
  1401. # 2 "test.cc" 2
  1402.  
  1403.  
  1404. main()
  1405. {
  1406.   Vector<double,3> a(cin), b(cin), c(a+b);
  1407.   c *= 3.;
  1408.   cout << c << endl;
  1409.   Vector<double,3> d(0);
  1410.   d = c - b;
  1411.   cout << d << endl;
  1412.   double e = (-d)*a;
  1413.   cout << e << endl;
  1414. }
  1415.  
  1416.