rfg@MCC.COM (Ron Guilmette) (05/04/89)
The following program causes G++ 1.35-.0-/Sun3 to abort. ------------------------------------------------------------------ // Check that it is legal to use the address of the current // function as one of the default arguments to the function // itself. void cheshire_cat (void* parm = (void*) &cheshire_cat); void cheshire_2 (void* parm = (void*) &cheshire_2) { } class base { private: void cheshire_3 (void* parm = (void*) &base::cheshire_3); public: void cheshire_4 (void* parm = (void*) &base::cheshire_4); }; int main () { return 0; } void base::cheshire_3 (void* parm = (void*) &base::cheshire_3) { } void cheshire_4 (void* parm = (void*) &base::cheshire_4) { } --------------------------------------------------------------------- /usr/local/src/src/g++/build/sun3/1.35-.0-.0/g++ -B/usr/local/src/src/g++/build/sun3/1.35-.0-.0/ -Wall -Wwrite-strings -g -S -v a028.C g++ version 1.35.0-.0 /usr/local/src/src/g++/build/sun3/1.35-.0-.0/cpp -+ -v -undef -D__GNU__ -D__GNUG__ -Dmc68000 -Dsun -Dunix -D__mc68000__ -D__sun__ -D__unix__ -Wall -D__HAVE_68881__ -Dmc68020 a028.C /tmp/cca20684.cpp GNU CPP version 1.35.0-.0 /usr/local/src/src/g++/build/sun3/1.35-.0-.0/c++ /tmp/cca20684.cpp -quiet -dumpbase a028.C -Wall -Wwrite-strings -noreg -version -G -o a028.s GNU C++ version 1.35.0-.0 (68k, MIT syntax) compiled by GNU C version 1.34.1. a028.C:5: `cheshire_cat' undeclared, outside of functions a028.C:7: `cheshire_2' undeclared, outside of functions a028.C:13: field `cheshire_3' is not a member of type `base' a028.C:15: field `cheshire_4' is not a member of type `base' a028.C:24: sorry, not implemented: that operation not supported for default parameters In method void base::cheshire_3 (void *: a028.C:24: conflicting types for `void base::cheshire_3 (void *' a028.C:13: previous declaration of `void base::cheshire_3 (void *' /usr/local/src/src/g++/build/sun3/1.35-.0-.0/g++: Program c++ got fatal signal 6.
rfg@MCC.COM (Ron Guilmette) (05/04/89)
The compiler does not check that type conversion operators must
have at least one argument.
It also looks like the error messages could be made more consistant
for all of the following cases.
b047 had missed error(s) as follows:
36: int operator int (); // ERROR
38: base operator base (); // ERROR
b047: FAILED
-------------------------------------------------------------------
// Check that it is illegal to declare unary operators with
// less than one argument. Check type conversions as well
// as normal operators.
struct base {
int member;
};
// Unary +
int operator + (); // ERROR
// unary -
int operator - (); // ERROR
// unary & (i.e. address of)
int operator & (); // ERROR
int operator ~ (); // ERROR
int operator ! (); // ERROR
int operator ++ (); // ERROR
int operator -- (); // ERROR
int operator [] (); // ERROR
int operator () (); // ERROR
int operator -> (); // ERROR
void* operator new (); // ERROR
void operator delete (); // ERROR
int operator int (); // ERROR
base operator base (); // ERROR
----------------------------------------------------------------------------
/usr/local/src/src/g++/build/sun3/1.35-.0-.0/g++ -B/usr/local/src/src/g++/build/sun3/1.35-.0-.0/ -Wall -Wwrite-strings -g -S -v b047.C
g++ version 1.35.0-.0
/usr/local/src/src/g++/build/sun3/1.35-.0-.0/cpp -+ -v -undef -D__GNU__ -D__GNUG__ -Dmc68000 -Dsun -Dunix -D__mc68000__ -D__sun__ -D__unix__ -Wall -D__HAVE_68881__ -Dmc68020 b047.C /tmp/cca20720.cpp
GNU CPP version 1.35.0-.0
/usr/local/src/src/g++/build/sun3/1.35-.0-.0/c++ /tmp/cca20720.cpp -quiet -dumpbase b047.C -Wall -Wwrite-strings -noreg -version -G -o b047.s
GNU C++ version 1.35.0-.0 (68k, MIT syntax) compiled by GNU C version 1.34.1.
b047.C:10: wrong number of parameters to `operator +'
b047.C:10: `operator +' must have at least one class type
b047.C:10: operator has no user-defined argument type
b047.C:13: wrong number of parameters to `operator -'
b047.C:13: `operator -' must have at least one class type
b047.C:13: operator has no user-defined argument type
b047.C:16: wrong number of parameters to `operator &'
b047.C:16: `operator &' must have at least one class type
b047.C:16: operator has no user-defined argument type
b047.C:18: wrong number of parameters to `operator ~'
b047.C:18: `operator ~' must have at least one class type
b047.C:18: operator has no user-defined argument type
b047.C:20: wrong number of parameters to `operator !'
b047.C:20: `operator !' must have at least one class type
b047.C:20: operator has no user-defined argument type
b047.C:22: `operator ++' must have at least one class type
b047.C:22: operator has no user-defined argument type
b047.C:24: `operator --' must have at least one class type
b047.C:24: operator has no user-defined argument type
b047.C:26: wrong number of parameters to `operator []'
b047.C:26: `operator []' must have at least one class type
b047.C:26: operator has no user-defined argument type
b047.C:28: `operator ()' must have at least one class type
b047.C:28: operator has no user-defined argument type
b047.C:30: `operator ->' must have at least one class type
b047.C:30: operator has no user-defined argument type
b047.C:32: operator has no user-defined argument type
b047.C:32: conflicting types for `void *__builtin_new ()'
(null):0: previous declaration of `void *__builtin_new (long int)'
b047.C:34: operator has no user-defined argument type
b047.C:34: conflicting types for `void __builtin_delete ()'
(null):0: previous declaration of `void __builtin_delete (void *)'
rfg@MCC.COM (Ron Guilmette) (05/04/89)
The following source file causes G++ 1.35-.0-/Sun3 to SEGFAULT. ----------------------------------------------------------------------- // Check that it is illegal to declare unary operators with // more than one formal argument (for global operators) or more // than zero formal arguments (for member operators). Check // type conversions as well as normal operators. struct st { int member; }; // Unary + could be binary //int operator + (st st1, st st2); // unary - could be binary //int operator - (st st1, st st2); // unary & could be binary //int operator & (st st1, st st2); // unary * could be binary //int operator * (st st1, st st2); int operator ~ (st st1, st st2); // ERROR int operator ! (st st1, st st2); // ERROR int operator ++ (st st1, st st2); // ERROR int operator -- (st st1, st st2); // ERROR int operator ( ) (st st1, st st2); // ERROR int operator -> (st st1, st st2); // ERROR void* operator new (st st1, st st2); // ERROR void operator delete (st st1, st st2); // ERROR int operator int (st st1, st st2); // ERROR st operator st (st st1, st st2); // ERROR struct base { // Unary + could be binary //int operator + (st st2); // unary - could be binary //int operator - (st st2); // unary & could be binary //int operator & (st st2); // unary * could be binary //int operator * (st st2); int operator ~ (st st2); // ERROR int operator ! (st st2); // ERROR int operator ++ (st st2); // ERROR int operator -- (st st2); // ERROR int operator ( ) (st st2); // ERROR int operator -> (st st2); // ERROR void* operator new (st st2); // ERROR void operator delete (st st2); // ERROR int operator int (st st2); // ERROR st operator st (st st2); // ERROR base operator base (st st2); // ERROR }; ----------------------------------------------------------------------- /usr/local/src/src/g++/build/sun3/1.35-.0-.0/g++ -B/usr/local/src/src/g++/build/sun3/1.35-.0-.0/ -Wall -Wwrite-strings -g -S -v b048.C g++ version 1.35.0-.0 /usr/local/src/src/g++/build/sun3/1.35-.0-.0/cpp -+ -v -undef -D__GNU__ -D__GNUG__ -Dmc68000 -Dsun -Dunix -D__mc68000__ -D__sun__ -D__unix__ -Wall -D__HAVE_68881__ -Dmc68020 b048.C /tmp/cca20861.cpp GNU CPP version 1.35.0-.0 /usr/local/src/src/g++/build/sun3/1.35-.0-.0/c++ /tmp/cca20861.cpp -quiet -dumpbase b048.C -Wall -Wwrite-strings -noreg -version -G -o b048.s /usr/local/src/src/g++/build/sun3/1.35-.0-.0/g++: Program c++ got fatal signal 11.
rfg@MCC.COM (Ron Guilmette) (05/04/89)
In the following source file, errors are not properly flagged for attempts
to give default arguments within (unary) operator declaration formal argument
lists. Also, a "syntax error" *is* reported for (apparently) no reason.
b062 had missed error(s) as follows:
14: int operator + (st st1 = st_object); // ERROR
17: int operator - (st st1 = st_object); // ERROR
20: int operator & (st st1 = st_object); // ERROR
23: int operator * (st st1 = st_object); // ERROR
25: int operator ~ (st st1 = st_object); // ERROR
27: int operator ! (st st1 = st_object); // ERROR
29: int operator ++ (st st1 = st_object); // ERROR
31: int operator -- (st st1 = st_object); // ERROR
33: int operator ( ) (st st1 = st_object); // ERROR
b062: FAILED
--------------------------------------------------------------------------
// Check that it is illegal to declare unary operators with
// a default value for the formal argument. Check type
// conversions as well as normal operators.
struct st {
int member;
};
st st_object;
int int_object;
void* voidp_object;
// Unary + could be binary
int operator + (st st1 = st_object); // ERROR
// unary - could be binary
int operator - (st st1 = st_object); // ERROR
// unary & could be binary
int operator & (st st1 = st_object); // ERROR
// unary * could be binary
int operator * (st st1 = st_object); // ERROR
int operator ~ (st st1 = st_object); // ERROR
int operator ! (st st1 = st_object); // ERROR
int operator ++ (st st1 = st_object); // ERROR
int operator -- (st st1 = st_object); // ERROR
int operator ( ) (st st1 = st_object); // ERROR
int operator -> (st st1 = st_object); // ERROR
void* operator new (int size = int_object); // ERROR
void operator delete (void* voidp_arg = voidp_object); // ERROR
int operator int (st st1 = st_object); // ERROR
st operator st (st st1 = st_object); // ERROR
--------------------------------------------------------------------------
g++-new -Wall -Wwrite-strings -g -S -v b062.C
g++ version 1.35.0-.0
/usr/local/src/lib/sun3/g++-1.35-.0-.0/gcc-cpp -+ -v -undef -D__GNU__ -D__GNUG__ -Dmc68000 -Dsun -Dunix -D__mc68000__ -D__sun__ -D__unix__ -Wall -D__HAVE_68881__ -Dmc68020 b062.C /tmp/cca22937.cpp
GNU CPP version 1.35.0-.0
/usr/local/src/lib/sun3/g++-1.35-.0-.0/gcc-c++ /tmp/cca22937.cpp -quiet -dumpbase b062.C -Wall -Wwrite-strings -noreg -version -G -o b062.s
GNU C++ version 1.35.0-.0 (68k, MIT syntax) compiled by GNU C version 1.34.1.
b062.C:35: parse error before `st'
b062.C:35: aggregate value used where an integer was expected
b062.C:35: parse error before `)'
b062.C:37: operator has no user-defined argument type
b062.C:37: conflicting types for `void *__builtin_new (int (= int_object ))'
(null):0: previous declaration of `void *__builtin_new (long int)'
b062.C:39: operator has no user-defined argument type
b062.C:41: operator <typename> requires empty parameter list
b062.C:43: operator <typename> requires empty parameter list
b062.C:33: warning: `int operator () (struct st (= st_object ))' defined but not used
b062.C:31: warning: `int operator -- (struct st (= st_object ))' defined but not used
b062.C:29: warning: `int operator ++ (struct st (= st_object ))' defined but not used
b062.C:27: warning: `int operator ! (struct st (= st_object ))' defined but not used
b062.C:25: warning: `int operator ~ (struct st (= st_object ))' defined but not used
b062.C:23: warning: `int operator (unary *) (struct st (= st_object ))' defined but not used
b062.C:20: warning: `int operator (unary &) (struct st (= st_object ))' defined but not used
b062.C:17: warning: `int operator - (struct st (= st_object ))' defined but not used
b062.C:14: warning: `int operator (unary +) (struct st (= st_object ))' defined but not used