public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/65357] New: aggressive loop optimization not correct
@ 2015-03-09  2:26 weiming at ms1 dot url.com.tw
  2015-03-09  4:18 ` [Bug c/65357] " trippels at gcc dot gnu.org
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: weiming at ms1 dot url.com.tw @ 2015-03-09  2:26 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 65357
           Summary: aggressive loop optimization not correct
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: weiming at ms1 dot url.com.tw

source:

#include <stdio.h>
#include <stdlib.h>

void    addlist(int n, int *list)
{
    int    i;
    for (i=0; i<n; i++)
    {
        *list++=*list+10;
        *list++=*list+11;
    }
}

int    tlist[10]={ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };

void    main(void)
{
    int    i;
    addlist(5, tlist);
    for (i=0; i<10; i++)
    {
        fprintf(stdout, "%d: %d\n", i, tlist[i]);
    }
}

makefile:
tt.exe: tt.c
    gcc -O3 -o $@ $<

result of gcc 4.7.3:
0: 10
1: 12
2: 12
3: 14
4: 14
5: 16
6: 16
7: 18
8: 18
9: 20

result of gcc 4.8.4 and 4.9.2:
0: 11
1: 13
2: 13
3: 15
4: 15
5: 17
6: 17
7: 19
8: 19
9: 11

which is correct?


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

* [Bug c/65357] aggressive loop optimization not correct
  2015-03-09  2:26 [Bug c/65357] New: aggressive loop optimization not correct weiming at ms1 dot url.com.tw
@ 2015-03-09  4:18 ` trippels at gcc dot gnu.org
  2015-03-09  5:08 ` pinskia at gcc dot gnu.org
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: trippels at gcc dot gnu.org @ 2015-03-09  4:18 UTC (permalink / raw)
  To: gcc-bugs

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

Markus Trippelsdorf <trippels at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
                 CC|                            |trippels at gcc dot gnu.org
         Resolution|---                         |INVALID

--- Comment #1 from Markus Trippelsdorf <trippels at gcc dot gnu.org> ---
Both, because you invoke undefined behavior.
https://gcc.gnu.org/bugs/#nonbugs_c


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

* [Bug c/65357] aggressive loop optimization not correct
  2015-03-09  2:26 [Bug c/65357] New: aggressive loop optimization not correct weiming at ms1 dot url.com.tw
  2015-03-09  4:18 ` [Bug c/65357] " trippels at gcc dot gnu.org
@ 2015-03-09  5:08 ` pinskia at gcc dot gnu.org
  2015-03-09  5:47 ` weiming at ms1 dot url.com.tw
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: pinskia at gcc dot gnu.org @ 2015-03-09  5:08 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
That is addlist goes one past the end of the array tlist.


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

* [Bug c/65357] aggressive loop optimization not correct
  2015-03-09  2:26 [Bug c/65357] New: aggressive loop optimization not correct weiming at ms1 dot url.com.tw
  2015-03-09  4:18 ` [Bug c/65357] " trippels at gcc dot gnu.org
  2015-03-09  5:08 ` pinskia at gcc dot gnu.org
@ 2015-03-09  5:47 ` weiming at ms1 dot url.com.tw
  2015-03-09  6:14 ` weiming at ms1 dot url.com.tw
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: weiming at ms1 dot url.com.tw @ 2015-03-09  5:47 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from Weiming Shih <weiming at ms1 dot url.com.tw> ---
I see. Thank you.


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

* [Bug c/65357] aggressive loop optimization not correct
  2015-03-09  2:26 [Bug c/65357] New: aggressive loop optimization not correct weiming at ms1 dot url.com.tw
                   ` (2 preceding siblings ...)
  2015-03-09  5:47 ` weiming at ms1 dot url.com.tw
@ 2015-03-09  6:14 ` weiming at ms1 dot url.com.tw
  2015-03-09  8:33 ` jakub at gcc dot gnu.org
  2015-03-09  8:47 ` pinskia at gcc dot gnu.org
  5 siblings, 0 replies; 7+ messages in thread
From: weiming at ms1 dot url.com.tw @ 2015-03-09  6:14 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 from Weiming Shih <weiming at ms1 dot url.com.tw> ---
How can I get a warning for such an undefined behavior?


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

* [Bug c/65357] aggressive loop optimization not correct
  2015-03-09  2:26 [Bug c/65357] New: aggressive loop optimization not correct weiming at ms1 dot url.com.tw
                   ` (3 preceding siblings ...)
  2015-03-09  6:14 ` weiming at ms1 dot url.com.tw
@ 2015-03-09  8:33 ` jakub at gcc dot gnu.org
  2015-03-09  8:47 ` pinskia at gcc dot gnu.org
  5 siblings, 0 replies; 7+ messages in thread
From: jakub at gcc dot gnu.org @ 2015-03-09  8:33 UTC (permalink / raw)
  To: gcc-bugs

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

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

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

--- Comment #5 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Perhaps by enabling warnings?  E.g. with -Wall you get all the important
warnings:
warning: operation on ‘list’ may be undefined [-Wsequence-point]
(twice) and
warning: return type of ‘main’ is not ‘int’ [-Wmain]
>From gcc-bugs-return-479757-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Mon Mar 09 08:36:55 2015
Return-Path: <gcc-bugs-return-479757-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org>
Delivered-To: listarch-gcc-bugs@gcc.gnu.org
Received: (qmail 90920 invoked by alias); 9 Mar 2015 08:36:55 -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 90861 invoked by uid 48); 9 Mar 2015 08:36:52 -0000
From: "mikpelinux at gmail dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug target/65358] wrong parameter passing code with tail call optimization on arm
Date: Mon, 09 Mar 2015 08:36:00 -0000
X-Bugzilla-Reason: CC
X-Bugzilla-Type: changed
X-Bugzilla-Watch-Reason: None
X-Bugzilla-Product: gcc
X-Bugzilla-Component: target
X-Bugzilla-Version: 5.0
X-Bugzilla-Keywords: wrong-code
X-Bugzilla-Severity: critical
X-Bugzilla-Who: mikpelinux at gmail dot com
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:
Message-ID: <bug-65358-4-B3qaA3bjeb@http.gcc.gnu.org/bugzilla/>
In-Reply-To: <bug-65358-4@http.gcc.gnu.org/bugzilla/>
References: <bug-65358-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: 2015-03/txt/msg00901.txt.bz2
Content-length: 305

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

--- Comment #6 from Mikael Pettersson <mikpelinux at gmail dot com> ---
(In reply to Honggyu Kim from comment #4)

> Can I add this testcase with your modification as my first gcc contribution?
> :)

Sure, just attach it to this PR as a new test case.


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

* [Bug c/65357] aggressive loop optimization not correct
  2015-03-09  2:26 [Bug c/65357] New: aggressive loop optimization not correct weiming at ms1 dot url.com.tw
                   ` (4 preceding siblings ...)
  2015-03-09  8:33 ` jakub at gcc dot gnu.org
@ 2015-03-09  8:47 ` pinskia at gcc dot gnu.org
  5 siblings, 0 replies; 7+ messages in thread
From: pinskia at gcc dot gnu.org @ 2015-03-09  8:47 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #6 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
I missed there was a sequence point issue there too :).


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

end of thread, other threads:[~2015-03-09  8:47 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-03-09  2:26 [Bug c/65357] New: aggressive loop optimization not correct weiming at ms1 dot url.com.tw
2015-03-09  4:18 ` [Bug c/65357] " trippels at gcc dot gnu.org
2015-03-09  5:08 ` pinskia at gcc dot gnu.org
2015-03-09  5:47 ` weiming at ms1 dot url.com.tw
2015-03-09  6:14 ` weiming at ms1 dot url.com.tw
2015-03-09  8:33 ` jakub at gcc dot gnu.org
2015-03-09  8:47 ` pinskia 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).