public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
* java/4022: ?: precedence is wrong.
@ 2001-08-14 12:46 apbianco
  0 siblings, 0 replies; 4+ messages in thread
From: apbianco @ 2001-08-14 12:46 UTC (permalink / raw)
  To: gcc-gnats; +Cc: mjr

>Number:         4022
>Category:       java
>Synopsis:       ?: precedence is wrong.
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Tue Aug 14 12:46:01 PDT 2001
>Closed-Date:
>Last-Modified:
>Originator:     Alex Petit-Bianco
>Release:        3.0 and trunk.
>Organization:
>Environment:
Most likely all. x86/linux definitively.
>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

A core dump happens when this is done in a toString method:

public class Test {
    public static void main(String[] args) {
        System.out.println(new Test());
    }

    public String toString() {
        String s = null;
        return "foo" + s != null ? s : "";
    }
}

>How-To-Repeat:
Build the examples above.
>Fix:
Not yet.
>Release-Note:
>Audit-Trail:
>Unformatted:
----gnatsweb-attachment----
Content-Type: application/octet-stream; name="null"
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename="null"


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: java/4022: ?: precedence is wrong.
@ 2001-08-16 10:32 tromey
  0 siblings, 0 replies; 4+ messages in thread
From: tromey @ 2001-08-16 10:32 UTC (permalink / raw)
  To: apbianco, gcc-bugs, gcc-prs, java-prs, mjr, nobody, tromey

Synopsis: ?: precedence is wrong.

Responsible-Changed-From-To: unassigned->tromey
Responsible-Changed-By: tromey
Responsible-Changed-When: Thu Aug 16 10:32:27 2001
Responsible-Changed-Why:
    I handled it.
State-Changed-From-To: open->closed
State-Changed-By: tromey
State-Changed-When: Thu Aug 16 10:32:27 2001
State-Changed-Why:
    This isn't a bug.
    `+' has higher precedence than `?:'.

http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view&pr=4022&database=gcc


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: java/4022: ?: precedence is wrong.
@ 2001-08-15 23:56 Daniel Jacobowitz
  0 siblings, 0 replies; 4+ messages in thread
From: Daniel Jacobowitz @ 2001-08-15 23:56 UTC (permalink / raw)
  To: nobody; +Cc: gcc-prs

The following reply was made to PR java/4022; it has been noted by GNATS.

From: Daniel Jacobowitz <drow@mvista.com>
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


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: java/4022: ?: precedence is wrong.
@ 2001-08-15 19:36 Tom Tromey
  0 siblings, 0 replies; 4+ messages in thread
From: Tom Tromey @ 2001-08-15 19:36 UTC (permalink / raw)
  To: nobody; +Cc: gcc-prs

The following reply was made to PR java/4022; it has been noted by GNATS.

From: Tom Tromey <tromey@redhat.com>
To: apbianco@redhat.com
Cc: gcc-gnats@gcc.gnu.org, mjr@anarcast.net
Subject: Re: java/4022: ?: precedence is wrong.
Date: 15 Aug 2001 21:02:53 -0600

 I'm not convinced this is really a bug.
 There is a thread on this topic:
 
     http://gcc.gnu.org/ml/java/2001-08/msg00059.html
 
 Tom


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2001-08-16 10:32 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-08-14 12:46 java/4022: ?: precedence is wrong apbianco
2001-08-15 19:36 Tom Tromey
2001-08-15 23:56 Daniel Jacobowitz
2001-08-16 10:32 tromey

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).