bug in g++ error output

Tom Tromey tromey@cygnus.com
Sun Feb 27 13:37:00 GMT 2000


I'm using a relatively new cvs gcc.

I have code that looks like this:

  try
    {
      _Jv_JNI_LocalFrame *frame
	= (_Jv_JNI_LocalFrame *) _Jv_Malloc (sizeof (_Jv_JNI_LocalFrame)
					     + size * sizeof (jobject));
    }
  catch (jthrowable t)
    {
      env->ex = t;
      return JNI_ERR;
    }

  frame->marker = true;

The bug here is that `frame' is declared inside the `try', but used
after the `try'.  Oops.

g++ gives a strange message in this case:

../../../libgcj/libjava/jni.cc: In function `jint
../../../libgcj/libjava/jni.cc: _Jv_JNI_EnsureLocalCapacity (JNIEnv *,
../../../libgcj/libjava/jni.cc: __java_int)':
../../../libgcj/libjava/jni.cc:188: warning: unused variable `
../../../libgcj/libjava/jni.cc:188: warning: _Jv_JNI_LocalFrame *frame'
../../../libgcj/libjava/jni.cc:197: `frame' undeclared (first use this
../../../libgcj/libjava/jni.cc:197: function)
../../../libgcj/libjava/jni.cc:197: (Each undeclared identifier is
../../../libgcj/libjava/jni.cc:197: reported only once
../../../libgcj/libjava/jni.cc:197: for each function it appears in.)

Look at the two lines that say `188: warning: '.  I find this strange
because g++ has apparently chosen to word wrap the message in a way
that is hard to read.  I think it would be better to format those
lines like this:

../../../libgcj/libjava/jni.cc:188: warning: unused variable
../../../libgcj/libjava/jni.cc:188: `_Jv_JNI_LocalFrame *frame'

Tom


More information about the Gcc-bugs mailing list