Article View: gnu.g++.bug
Article #270bugs in g++ 2.1
From: Thomas M. Breuel
Date: Thu, 16 Apr 1992 13:01
Date: Thu, 16 Apr 1992 13:01
224 lines
6103 bytes
6103 bytes
Here is a collection of bugs or problems with gcc/g++ version 2.1. To
keep the output small, I have run "g++ -c -v" only for the first file
(BUG01.cc). The others are essentially the same.
This is on a Sun IPC running SunOS 4.1.1.
==== BUG01.cc
1 // COMPILER INCORRECTLY CLAIMS THAT ARGUMENT TO twice HAS UNKNOWN TYPE
2
3 template <class F> void twice(F f) {f(); f();}
4
5 int f() {return 3;}
6
7 main() {
8 twice(f);
9 }
Reading specs from /usr/local/lib/gcc-lib/sparc/2.1/specs
gcc version 2.1
/usr/local/lib/gcc-lib/sparc/2.1/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 BUG01.cc /tmp/cca12018.i
GNU CPP version 2.1 (sparc)
/usr/local/lib/gcc-lib/sparc/2.1/cc1plus /tmp/cca12018.i -quiet -dumpbase BUG01.cc -version -o /tmp/cca12018.s
GNU C++ version 2.1 (sparc) compiled by GNU C version 2.1.
BUG01.cc: In function `int main ()':
BUG01.cc:8: bad argument 0 for function `twice__F? (<unknown type>)' (type was <unknown type>)
Comment: for all other builtint type, template functions recognize
the builtin operators that can be applied to the type (e.g.,
int/operator+). Why not function-pointer/operator()?
==== BUG02.cc
1 // STATIC MEMBER FUNCTIONS CANNOT BE TEMPLATES? WHY?
2
3 struct seq {
4 template <class S,class E>
5 static void fill(E &e,S &s) {}
6 };
BUG02.cc:4: parse error before `template'
BUG02.cc:4: parse error before `>'
==== BUG05.cc
1 template <class T> struct Counted {
2 int *i;
3 // SYNTAX ERROR ON FOLLOWING LINE
4 Counted(Counted<T> &src) {}
5 };
6
7 main() {
8 Counted<int> p;
9 }
BUG05.cc:4: parse error before `>'
BUG05.cc:4: syntax error before `)'
BUG05.cc:5: parse error at end of class template
(what's the difference between a "parse error" and a "syntax error"
anyway?)
==== BUG07.cc
1 // THE C++ FRONTEND DOESN'T RECOGNIZE NESTED FUNCTIONS
2
3 main() {
4 int x;
5 void f() {x++;}
6 f();
7 }
BUG07.cc: In function `int main ()':
BUG07.cc:5: parse error before `{'
BUG07.cc: At top level:
BUG07.cc:6: warning: data definition has no type or storage class
BUG07.cc:7: parse error before `}'
Comment: this isn't really a bug, but since gcc 2.1 supports it for
C, it would be nice if g++ 2.1 supported it for C++.
==== BUG08.cc
1 template <class T> struct Array {
2 T a[100];
3 T &operator()(int i) {return a[i];}
4 };
5
6 main() {
7 Array<int> a;
8 Array<Array<int>> b;
9 }
BUG08.cc: In function `int main ()':
BUG08.cc:8: parse error before `;'
==== BUG14.cc
1 template <class A,class TA>
2 struct TX {
3 A i;
4 TA(TA &x) {i=x;}
5 void operator=(TA &x) {i=x;}
6 };
7
8 template <class A> struct X:TX<A,X> {};
9
10 main() {
11 X<int> a;
12 }
BUG14.cc: In method `void TX<int ,X<int>>::operator = (struct X<int>&)':
BUG14.cc:5: aggregate value used where an integer was expected
BUG14.cc: In method `int TX<int ,X<int>>::TA (struct X<int>&)':
BUG14.cc:4: aggregate value used where an integer was expected
BUG14.cc:4: warning: control reaches end of non-void function
Comment: this is probably not a legal program, but the error messages
seem to be missing the point.
==== BUG15.cc
1 extern "C" {
2 void printf();
3 };
4
5 struct X {
6 int i;
7 };
8
9 struct Y:X {
10 Y() {}
11 Y(X &x) {i=x.i; printf("got here\n");}
12 void operator=(X &x) {i=x.i;}
13 };
14
15 main() {
16 Y x;
17 // I don't think this should invoke Y::Y(X &x)...
18 // shouldn't it instead use the default constructor Y::Y(Y &y) ?
19 Y y(x);
20 }
$ gcc BUG15.cc
$ a.out
got here
$
==== BUG23.cc
1 template <class T>
2 struct A {int x;};
3
4 A<int> f() {
5 A<int> a={3};
6 return a;
7 }
BUG23.cc:4: semicolon missing after declaration of `A<int>'
BUG23.cc: In function `int f ()':
BUG23.cc:6: aggregate value used where an integer was expected
==== BUG25.cc
1 typedef float (*G)(float,float);
2
3 void f(G g) {
4 g(3.0,4.0);
5 }
6
7 main() {
8 f(operator+);
9 }
BUG25.cc: In function `int main ()':
BUG25.cc:8: operator + not defined
Comment: I'm not sure whether this is according to ARM, but it
would be nice if it worked...
==== BUG28.cc
1 typedef float (*float_binop)(float,float);
2
3 inline float plus(float x,float y) {return x+y;}
4
5 inline float f(float_binop g,float x) {g(g(x,x),g(x,x));}
6
7 main() {
8 volatile float *r=(volatile float *)4096;
9 float x;
10 x=*r;
11 x=f(plus,x);
12 *r=x;
13 }
Comment: The compiler fails to inline "plus" (it does inline "f"). Not
really a bug, but unpleasant nonetheless.
==== BUG29.cc
1 struct A {
2 int x;
3 };
4
5 struct B:A {
6 B(int x):x(x) {}
7 B &operator=(B &other) {
8 A::operator=(other);
9 }
10 };
11
12 main() {
13 B x(17);
14 B y(13);
15 y=x;
16 }
BUG29.cc: In method `struct B& B::operator = (struct B&)':
BUG29.cc:8: no method `A::operator ='
BUG29.cc:9: warning: control reaches end of non-void function
Comment: Why can't I call the automatically generated assignment
operator?
Technical Details
Message-ID:
<9204161301.AA12091@bambleweenie57>Path:
arc1-ca.pugleaf.net!sparky!uunet!cis.ohio-state.edu!ai.mit.edu!tmbShow Full Headers
Complete Article Headers
Newsgroups: gnu.g++.bug Path: arc1-ca.pugleaf.net!sparky!uunet!cis.ohio-state.edu!ai.mit.edu!tmb From: tmb@ai.mit.edu (Thomas M. Breuel) Subject: bugs in g++ 2.1 Message-ID: <9204161301.AA12091@bambleweenie57> Sender: gnulists@ai.mit.edu Organization: GNUs Not Usenet Distribution: gnu Date: Thu, 16 Apr 1992 13:01:08 GMT Approved: bug-g++@prep.ai.mit.edu Lines: 226