public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/61317] New: ones complement fails when using increment(++) into an array
@ 2014-05-26  8:55 richard at rjriley dot info
  2014-05-26  8:57 ` [Bug c/61317] " pinskia at gcc dot gnu.org
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: richard at rjriley dot info @ 2014-05-26  8:55 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61317

            Bug ID: 61317
           Summary: ones complement fails when using increment(++) into an
                    array
           Product: gcc
           Version: 4.8.2
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: richard at rjriley dot info

Created attachment 32855
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=32855&action=edit
Test program and results

When taking the one's complement of a number with the result going to an array
using an auto-incremented index, the new gcc produces incorrect values.

ints[j++]=~ints[j-1] & 0xFF; does not produce the same (correct) value as 
a = ~ints[j-1] & 0xFF; ints[j++] = a;


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

* [Bug c/61317] ones complement fails when using increment(++) into an array
  2014-05-26  8:55 [Bug c/61317] New: ones complement fails when using increment(++) into an array richard at rjriley dot info
@ 2014-05-26  8:57 ` pinskia at gcc dot gnu.org
  2014-05-26 10:50 ` richard at rjriley dot info
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: pinskia at gcc dot gnu.org @ 2014-05-26  8:57 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61317

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|---                         |INVALID

--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
>        ints[j++]=~ints[j-1] & 0xFF;

It is unspecified (in both C and C++ standards) if j++ can happen either before
or after the expression j-1 has been evaluated.


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

* [Bug c/61317] ones complement fails when using increment(++) into an array
  2014-05-26  8:55 [Bug c/61317] New: ones complement fails when using increment(++) into an array richard at rjriley dot info
  2014-05-26  8:57 ` [Bug c/61317] " pinskia at gcc dot gnu.org
@ 2014-05-26 10:50 ` richard at rjriley dot info
  2014-05-26 10:57 ` pinskia at gcc dot gnu.org
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: richard at rjriley dot info @ 2014-05-26 10:50 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61317

--- Comment #2 from Richard Riley <richard at rjriley dot info> ---
"When postfix ++ is applied to an lvalue the result is the value of the object
referred to by the lvalue.  After the result is noted, the object is
incremented in the same manner as for the prefix ++ operator.  The type of the
result is the same as the type of the lvalue expression."  Page 187, "The C
Programming Language" Kernighan and Ritchie, 1978


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

* [Bug c/61317] ones complement fails when using increment(++) into an array
  2014-05-26  8:55 [Bug c/61317] New: ones complement fails when using increment(++) into an array richard at rjriley dot info
  2014-05-26  8:57 ` [Bug c/61317] " pinskia at gcc dot gnu.org
  2014-05-26 10:50 ` richard at rjriley dot info
@ 2014-05-26 10:57 ` pinskia at gcc dot gnu.org
  2014-05-26 12:29 ` redi at gcc dot gnu.org
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: pinskia at gcc dot gnu.org @ 2014-05-26 10:57 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61317

--- Comment #3 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
(In reply to Richard Riley from comment #2)
> "When postfix ++ is applied to an lvalue the result is the value of the
> object referred to by the lvalue.  After the result is noted, the object is
> incremented in the same manner as for the prefix ++ operator.  The type of
> the result is the same as the type of the lvalue expression."  Page 187,
> "The C Programming Language" Kernighan and Ritchie, 1978

This just says what a++ does/is but it does not come into play here as we are
doing the correct thing a++ just is it done before or after a-1 expression. C
does not specify the order of execution if there is no sequence point. =, &,
and [] are not sequence points.


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

* [Bug c/61317] ones complement fails when using increment(++) into an array
  2014-05-26  8:55 [Bug c/61317] New: ones complement fails when using increment(++) into an array richard at rjriley dot info
                   ` (2 preceding siblings ...)
  2014-05-26 10:57 ` pinskia at gcc dot gnu.org
@ 2014-05-26 12:29 ` redi at gcc dot gnu.org
  2014-05-26 12:53 ` richard at rjriley dot info
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: redi at gcc dot gnu.org @ 2014-05-26 12:29 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61317

--- Comment #4 from Jonathan Wakely <redi at gcc dot gnu.org> ---
http://c-faq.com/expr/seqpoints.html


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

* [Bug c/61317] ones complement fails when using increment(++) into an array
  2014-05-26  8:55 [Bug c/61317] New: ones complement fails when using increment(++) into an array richard at rjriley dot info
                   ` (3 preceding siblings ...)
  2014-05-26 12:29 ` redi at gcc dot gnu.org
@ 2014-05-26 12:53 ` richard at rjriley dot info
  2014-05-26 13:14 ` mpolacek at gcc dot gnu.org
  2014-05-26 13:36 ` redi at gcc dot gnu.org
  6 siblings, 0 replies; 8+ messages in thread
From: richard at rjriley dot info @ 2014-05-26 12:53 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61317

--- Comment #5 from Richard Riley <richard at rjriley dot info> ---
(In reply to Jonathan Wakely from comment #4)
> http://c-faq.com/expr/seqpoints.html

If that is the case, shouldn't a[i] = i++ and such statements be flagged as a
compiler error?


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

* [Bug c/61317] ones complement fails when using increment(++) into an array
  2014-05-26  8:55 [Bug c/61317] New: ones complement fails when using increment(++) into an array richard at rjriley dot info
                   ` (4 preceding siblings ...)
  2014-05-26 12:53 ` richard at rjriley dot info
@ 2014-05-26 13:14 ` mpolacek at gcc dot gnu.org
  2014-05-26 13:36 ` redi at gcc dot gnu.org
  6 siblings, 0 replies; 8+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2014-05-26 13:14 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61317

Marek Polacek <mpolacek at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |mpolacek at gcc dot gnu.org

--- Comment #6 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
You should get a warning with -Wall:
warning: operation on ‘i’ may be undefined [-Wsequence-point]
>From gcc-bugs-return-452529-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Mon May 26 13:31:12 2014
Return-Path: <gcc-bugs-return-452529-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org>
Delivered-To: listarch-gcc-bugs@gcc.gnu.org
Received: (qmail 15819 invoked by alias); 26 May 2014 13:31:09 -0000
Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm
Precedence: bulk
List-Id: <gcc-bugs.gcc.gnu.org>
List-Archive: <http://gcc.gnu.org/ml/gcc-bugs/>
List-Post: <mailto:gcc-bugs@gcc.gnu.org>
List-Help: <mailto:gcc-bugs-help@gcc.gnu.org>
Sender: gcc-bugs-owner@gcc.gnu.org
Delivered-To: mailing list gcc-bugs@gcc.gnu.org
Received: (qmail 15763 invoked by uid 48); 26 May 2014 13:31:03 -0000
From: "ro at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug bootstrap/61320] New: [4.10 regression] ICE in jcf-parse.c:1622 (parse_class_file
Date: Mon, 26 May 2014 13:31:00 -0000
X-Bugzilla-Reason: CC
X-Bugzilla-Type: new
X-Bugzilla-Watch-Reason: None
X-Bugzilla-Product: gcc
X-Bugzilla-Component: bootstrap
X-Bugzilla-Version: 4.10.0
X-Bugzilla-Keywords:
X-Bugzilla-Severity: normal
X-Bugzilla-Who: ro at gcc dot gnu.org
X-Bugzilla-Status: UNCONFIRMED
X-Bugzilla-Priority: P3
X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org
X-Bugzilla-Target-Milestone: ---
X-Bugzilla-Flags:
X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter cc cf_gcchost cf_gcctarget cf_gccbuild
Message-ID: <bug-61320-4@http.gcc.gnu.org/bugzilla/>
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: 7bit
X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/
Auto-Submitted: auto-generated
MIME-Version: 1.0
X-SW-Source: 2014-05/txt/msg02221.txt.bz2
Content-length: 1960

https://gcc.gnu.org/bugzilla/show_bug.cgi?ida320

            Bug ID: 61320
           Summary: [4.10 regression] ICE in jcf-parse.c:1622
                    (parse_class_file
           Product: gcc
           Version: 4.10.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: bootstrap
          Assignee: unassigned at gcc dot gnu.org
          Reporter: ro at gcc dot gnu.org
                CC: ebotcazou at gcc dot gnu.org
              Host: sparc*-sun-solaris2.*
            Target: sparc*-sun-solaris2.*
             Build: sparc*-sun-solaris2.*

Between 20140520 (r210655) and 20140523 (r210861), Java bootstrap started to
FAIL
on Solaris/SPARC:

In file included from <built-in>:0:0:
/vol/gcc/src/hg/trunk/local/libjava/java/lang/Class.java:0:0: internal compiler
error: Bus Error
0x654d6b crash_signal
        /vol/gcc/src/hg/trunk/local/gcc/toplev.c:337
0x217e44 parse_class_file
        /vol/gcc/src/hg/trunk/local/gcc/java/jcf-parse.c:1622
0x218b5f java_parse_file()
        /vol/gcc/src/hg/trunk/local/gcc/java/jcf-parse.c:1971

Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 1 (LWP 1)]
0x00217e44 in parse_class_file ()
    at /vol/gcc/src/hg/trunk/local/gcc/java/jcf-parse.c:1622
1622                  int line = GET_u2 (ptr);
(gdb) where
#0  0x00217e44 in parse_class_file ()
    at /vol/gcc/src/hg/trunk/local/gcc/java/jcf-parse.c:1622
#1  0x00218b60 in java_parse_file ()
    at /vol/gcc/src/hg/trunk/local/gcc/java/jcf-parse.c:1971
#2  0x00654db8 in compile_file ()
    at /vol/gcc/src/hg/trunk/local/gcc/toplev.c:548
#3  0x006573a4 in do_compile ()
    at /vol/gcc/src/hg/trunk/local/gcc/toplev.c:1915
#4  toplev_main (argc\x19, argv=0xffbff2dc)
    at /vol/gcc/src/hg/trunk/local/gcc/toplev.c:1991
#5  0x001ca974 in _start ()

Reghunt currently underway, couldn't reproduce in an i386-pc-solaris2.11 x
sparc-sun-solaris2.11 cross, unfortunately.

  Rainer


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

* [Bug c/61317] ones complement fails when using increment(++) into an array
  2014-05-26  8:55 [Bug c/61317] New: ones complement fails when using increment(++) into an array richard at rjriley dot info
                   ` (5 preceding siblings ...)
  2014-05-26 13:14 ` mpolacek at gcc dot gnu.org
@ 2014-05-26 13:36 ` redi at gcc dot gnu.org
  6 siblings, 0 replies; 8+ messages in thread
From: redi at gcc dot gnu.org @ 2014-05-26 13:36 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61317

--- Comment #7 from Jonathan Wakely <redi at gcc dot gnu.org> ---
Undefined behaviour does not mean you get a compiler error.


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

end of thread, other threads:[~2014-05-26 13:36 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-05-26  8:55 [Bug c/61317] New: ones complement fails when using increment(++) into an array richard at rjriley dot info
2014-05-26  8:57 ` [Bug c/61317] " pinskia at gcc dot gnu.org
2014-05-26 10:50 ` richard at rjriley dot info
2014-05-26 10:57 ` pinskia at gcc dot gnu.org
2014-05-26 12:29 ` redi at gcc dot gnu.org
2014-05-26 12:53 ` richard at rjriley dot info
2014-05-26 13:14 ` mpolacek at gcc dot gnu.org
2014-05-26 13:36 ` redi at gcc dot gnu.org

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