public inbox for java@gcc.gnu.org
 help / color / mirror / Atom feed
From: Mark Wielaard <mark@klomp.org>
To: java@gcc.gnu.org
Subject: Re: Mauve - the remainder
Date: Wed, 17 Apr 2002 16:24:00 -0000	[thread overview]
Message-ID: <1019084820.7820.154.camel@elsschot> (raw)
In-Reply-To: <1019080941.7866.133.camel@elsschot>

Hi,

On Thu, 2002-04-18 at 00:02, Mark Wielaard wrote:
> 
> FAIL: gnu.testlet.java.lang.StringBuffer.plus (number 1)
> 
> The following program returns false, but should return true:
> 
> public class SN
> {
>         public static void main(String[] args)
>         {
>                 System.out.println("null".equals(n(0) + ""));
>         }
> 
>         static String n(int i)
>         {
>                 if (i==0) return null; else return "x";
>         }
> }
> 
> The problem is that the String concatenation gets optimized away and
> since n(0) returns null it does not generate the string "null" but it
> generates the value null. The problem disappears when the return type of
> n() is changed to Object.

OK, the following optimization seems to be the problem:

diff -u -r1.353.2.17 parse.y
--- gcc/java/parse.y    15 Apr 2002 09:28:53 -0000      1.353.2.17
+++ gcc/java/parse.y    17 Apr 2002 22:50:38 -0000
@@ -13756,8 +13756,8 @@
     op2 = patch_string_cst (op2);
 
   /* If either one of the constant is null and the other non null
-     operand is a String object, return it. */
-  if (JSTRING_TYPE_P (TREE_TYPE (op1)) && !op2)
+     operand is a String constant, return it. */
+  if ((TREE_CODE (op1) == STRING_CST) && !op2)
     return op1;
 
   /* If OP1 isn't already a StringBuffer, create and

Or does this look to conservative?

Good night,

Mark

  reply	other threads:[~2002-04-17 23:07 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-04-17 15:54 Mark Wielaard
2002-04-17 16:24 ` Mark Wielaard [this message]
2002-04-18  8:31 ` Andrew Haley
2002-04-19 17:02 ` Mauve - the remainder (ieee_real_to_integer) Mark Wielaard
2002-04-19 18:05 ` Mauve - the remainder Tom Tromey

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1019084820.7820.154.camel@elsschot \
    --to=mark@klomp.org \
    --cc=java@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).