PR java/16927 [Was Re: PATCH for better assertion control.]
Andrew Haley
aph@redhat.com
Thu Sep 23 17:33:00 GMT 2004
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.
More information about the Java
mailing list