🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

template constructors with argument bug.

#1228
From: Krste Asanovic
Date: Sat, 21 Nov 1992 04:16
60 lines
1671 bytes
The following transcript shows a C++ program using templates that gets
a fatal signal with gcc-2.3.1, but compiles OK with gcc-2.2.2. This is
on a SPARC running SunOS Release 4.1.1.

Krste Asanovic,                   Computer Science Division, 
email: krste@cs.berkeley.edu      c/o 571 Evans Hall
phone: +1 (510) 642-4274 ext 143  University of California at Berkeley
fax:   +1 (510) 643-7684          CA 94720, USA

----------------------------------------------------------------------

icsib43:src>cat main.cc
template<class T>
class Vec
{
public:
    Vec(int nElements);
    ~Vec();

    int size();

protected:
    int n;
    T *p;
};

template<class T>
inline
Vec<T>::Vec(int nElements)
  : n(nElements)
{
    p = new T[nElements];
}

template<class T>
inline
Vec<T>::~Vec()
{
    delete[] p;
}

template<class T>
inline int
Vec<T>::size()
{
    return n;
}

main()
{
    Vec<int> a(3);

    return 0;
}
icsib43:src>gcc -o main main.cc
main.cc: In function `int  main ()':
main.cc:13: inconsistent return types for method `Vec' in class `Vec<int>'
gcc: Internal compiler error: program cc1plus got fatal signal 11
icsib43:src>gcc -V2.2.2 -o main main.cc
icsib43:src>
Technical Details
Message-ID: <9211210416.AA27828@icsib43.ICSI.Berkeley.EDU>
Path: arc1-ca.pugleaf.net!sparky!uunet!zaphod.mps.ohio-state.edu!cis.ohio-state.edu!icsi.berkeley.edu!krste

Show Full Headers
Complete Article Headers
Newsgroups: gnu.g++.bug
Path: arc1-ca.pugleaf.net!sparky!uunet!zaphod.mps.ohio-state.edu!cis.ohio-state.edu!icsi.berkeley.edu!krste
From: krste@icsi.berkeley.edu (Krste Asanovic)
Subject: template constructors with argument bug.
Message-ID: <9211210416.AA27828@icsib43.ICSI.Berkeley.EDU>
Sender: gnulists@ai.mit.edu
Organization: GNUs Not Usenet
Distribution: gnu
Date: Sat, 21 Nov 1992 04:16:51 GMT
Approved: bug-g++@prep.ai.mit.edu
Lines: 62