This is the mail archive of the java@gcc.gnu.org mailing list for the Java project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

PR java/16927 [Was Re: PATCH for better assertion control.]


This code:

  if (! enable_assertions (klass))
    {
      condition = build2 (TRUTH_ANDIF_EXPR, NULL_TREE,
			  boolean_false_node, condition);
      if (value == NULL_TREE)
	value = build_java_empty_stmt ();
      return build_if_else_statement (location, condition,
				      value, NULL_TREE);
    }

causes an ICE with code like

    public void bug(Integer i) {
        assert(i.intValue() == 0):
            i.toString() + "!";
    }

This happens because we build something like

  if (false && false)
    i.toString() + "!";

We must call patch_string() on every string concatenation before
generating code or doing assignment checks.  However, there's no path
in the compiler that does so in void context.

The obvious fix is not to generate code for the assertion at all -- it
cannot be executed -- but simply return a null statement.  However,
you've gone to some trouble here not to do the "obvious" thing.  Is
there a special reason why?  Maybe warnings for unused args or
something like that?

Thanks,
Andrew.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]