From mboxrd@z Thu Jan 1 00:00:00 1970 From: Daniel Jacobowitz To: nobody@gcc.gnu.org Cc: gcc-prs@gcc.gnu.org Subject: Re: java/4022: ?: precedence is wrong. Date: Wed, 15 Aug 2001 23:56:00 -0000 Message-id: <20010816065601.30306.qmail@sourceware.cygnus.com> X-SW-Source: 2001-08/msg00430.html List-Id: The following reply was made to PR java/4022; it has been noted by GNATS. From: Daniel Jacobowitz To: apbianco@redhat.com Cc: gcc-gnats@gcc.gnu.org, mjr@anarcast.net Subject: Re: java/4022: ?: precedence is wrong. Date: Wed, 15 Aug 2001 23:46:49 -0700 On Tue, Aug 14, 2001 at 07:39:18PM -0000, apbianco@redhat.com wrote: > >Description: > Consider this test case: > > public class Test { > public static void main(String[] args) { > String s = null; > System.out.println("foo" + s != null ? s : ""); > } > } > > $ ./test > null > > When enclosed in parentheses, it behaves normally: > > System.out.println("foo" + (s != null ? s : "")); > > $ ./test > foo I could be wrong, since my Java is rusty, but that's not the precedence of ?:. + has lower precedence than !=. "foo" + s is not equal to null, so s is printed, which is null. -- Daniel Jacobowitz Carnegie Mellon University MontaVista Software Debian GNU/Linux Developer