Path: utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!tut.cis.ohio-state.edu!MCC.COM!rfg From: rfg@MCC.COM (Ron Guilmette) Newsgroups: gnu.g++.bug Subject: BUG in G++ 1.35.0/sun3 Message-ID: <8906252134.AA20749@pink.aca.mcc.com> Date: 25 Jun 89 21:34:42 GMT Sender: daemon@tut.cis.ohio-state.edu Distribution: gnu Organization: GNUs Not Usenet Lines: 64 The following code fails to elicit an error on line 31 from G++ 1.35.0/sun3. Also, the error messages that *are* issued are sometimes misleading because this code (obviously) involves no "variable-size" objects. ---------------------------------------------------------------------------- // Check that a constant integer expression (which may include declared // constant objects) cannot be used in contexts which require a static // integer constant expression if any of the declared integer constant // objects only have tenative declarations, and not value definitions. // // Cases: // array length specifications // bitfield length specifications extern const int k2; // tenative declaration const int k4; // tenative declaration const int k8; // tenative declaration char global_array[((k2+7)*k4)/(k8-1)]; // ERROR struct base { char member_array[((k2+7)*k4)/(k8-1)]; // ERROR unsigned int bit_field_1:k2; // ERROR unsigned int bit_field_2:k2+k4; // ERROR unsigned int bit_field_3:7+k4; // ERROR unsigned int bit_field_4:7+(k4+k2); // ERROR unsigned int bit_field_5:(3+k4); // ERROR }; base global_base_object; int main () { base local_base_object; char local_array[((k2+7)*k4)/(k8-1)]; // ERROR - missed local_array[0] = 'x'; local_base_object.bit_field_5 = 0x7f; return 0; } const int k4 = 4; const int k8 = 8; ---------------------------------------------------------------------------- g++-1.35.0.0 -g -Wall -Wwrite-strings -v -S b077.C g++ version 1.35.0 /usr/local/src/lib/sun3/g++-1.35.0.0/gcc-cpp -+ -v -undef -D__GNU__ -D__GNUG__ -D__cplusplus -Dmc68000 -Dsun -Dunix -D__mc68000__ -D__sun__ -D__unix__ -Wall -D__HAVE_68881__ -Dmc68020 b077.C /tmp/cca20716.cpp GNU CPP version 1.35 /usr/local/src/lib/sun3/g++-1.35.0.0/gcc-cc1plus /tmp/cca20716.cpp -quiet -dumpbase b077.C -Wall -Wwrite-strings -noreg -version -G -o b077.s GNU C++ version 1.35.0 (68k, MIT syntax) compiled by GNU C version 1.35. b077.C:14: variable-size type declared outside of any function b077.C:18: variable-size type declared outside of any function b077.C:19: structure field `bit_field_1' width not an integer constant b077.C:20: structure field `bit_field_2' width not an integer constant b077.C:21: structure field `bit_field_3' width not an integer constant b077.C:22: structure field `bit_field_4' width not an integer constant b077.C:23: structure field `bit_field_5' width not an integer constant b077 had missed error(s) as follows: 31: char local_array[((k2+7)*k4)/(k8-1)]; // ERROR