This is the mail archive of the
java@gcc.gnu.org
mailing list for the Java project.
PR java/16927 [Was Re: PATCH for better assertion control.]
- From: Andrew Haley <aph at redhat dot com>
- To: Per Bothner <per at bothner dot com>
- Cc: java at gcc dot gnu dot org
- Date: Thu, 23 Sep 2004 18:33:21 +0100
- Subject: PR java/16927 [Was Re: PATCH for better assertion control.]
- References: <40526AED.6070807@bothner.com><40538F72.5030905@bothner.com>
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.