public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/54743] New: Large loop runs endingless
@ 2012-09-29  5:44 slbyan at gmail dot com
  2012-09-29  7:25 ` [Bug c/54743] " schwab@linux-m68k.org
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: slbyan at gmail dot com @ 2012-09-29  5:44 UTC (permalink / raw)
  To: gcc-bugs


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54743

             Bug #: 54743
           Summary: Large loop runs endingless
    Classification: Unclassified
           Product: gcc
           Version: 4.6.3
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: slbyan@gmail.com


When the loops is 1000000000, the -O3 or -O2 -funroll-loops make the code runs
fast enough(~17sec, on Intel(R) Core(TM)2 Duo CPU E7400 @ 2.80GHz), and when
double the loops (2000000000), the time doubles as expected. However, when
loops is 3000000000, the code runs hours without ending.
The code is:

#include <stdio.h>
static long double vec_a[16] ={
    1.0,2.0,3.0,4.0,
    11.0,22.0,33.0,44.0,
    111.0,222.0,333.0,444.0,
    1111.0,2222.0,3333.0,4444.0};
static long double vec_b[16] ={
    1.0,2.0,3.0,4.0,
    11.0,22.0,33.0,44.0,
    111.0,222.0,333.0,444.0,
    1111.0,2222.0,3333.0,4444.0};
static long MAX = 3000000000L;
int main(int argc, char** argv) {
    long double c = 0.0f;
    for (int i=0; i < MAX; ++i)
        for (int j=0; j<16;++j)
            c += vec_a[j]* vec_a[j];
    printf("%llf\n",c);
    return 0;
}


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

* [Bug c/54743] Large loop runs endingless
  2012-09-29  5:44 [Bug c/54743] New: Large loop runs endingless slbyan at gmail dot com
@ 2012-09-29  7:25 ` schwab@linux-m68k.org
  2012-09-29  7:48 ` slbyan at gmail dot com
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: schwab@linux-m68k.org @ 2012-09-29  7:25 UTC (permalink / raw)
  To: gcc-bugs


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54743

Andreas Schwab <schwab@linux-m68k.org> changed:

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

--- Comment #1 from Andreas Schwab <schwab@linux-m68k.org> 2012-09-29 07:25:34 UTC ---
3000000000L is bigger than INT_MAX.


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

* [Bug c/54743] Large loop runs endingless
  2012-09-29  5:44 [Bug c/54743] New: Large loop runs endingless slbyan at gmail dot com
  2012-09-29  7:25 ` [Bug c/54743] " schwab@linux-m68k.org
@ 2012-09-29  7:48 ` slbyan at gmail dot com
  2012-09-29  7:49 ` slbyan at gmail dot com
  2012-09-29  8:08 ` paolo.carlini at oracle dot com
  3 siblings, 0 replies; 5+ messages in thread
From: slbyan at gmail dot com @ 2012-09-29  7:48 UTC (permalink / raw)
  To: gcc-bugs


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54743

--- Comment #2 from 顏烈彬 <slbyan at gmail dot com> 2012-09-29 07:48:26 UTC ---
(In reply to comment #1)
You mean that i (as most INT_MAX) is always less than 30000000000L?
And, in a RH 2.6.18-164.el5, gcc Red Hat 4.1.2-52, it runs as (was) expected,
because it's buggy is gcc 4.1.2?

> 3000000000L is bigger than INT_MAX.


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

* [Bug c/54743] Large loop runs endingless
  2012-09-29  5:44 [Bug c/54743] New: Large loop runs endingless slbyan at gmail dot com
  2012-09-29  7:25 ` [Bug c/54743] " schwab@linux-m68k.org
  2012-09-29  7:48 ` slbyan at gmail dot com
@ 2012-09-29  7:49 ` slbyan at gmail dot com
  2012-09-29  8:08 ` paolo.carlini at oracle dot com
  3 siblings, 0 replies; 5+ messages in thread
From: slbyan at gmail dot com @ 2012-09-29  7:49 UTC (permalink / raw)
  To: gcc-bugs


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54743

--- Comment #3 from 顏烈彬 <slbyan at gmail dot com> 2012-09-29 07:49:12 UTC ---
(In reply to comment #1)
You mean that i (as most INT_MAX) is always less than 30000000000L?
And, in a RH 2.6.18-164.el5, gcc Red Hat 4.1.2-52, it runs as (was) expected,
because it's buggy is gcc 4.1.2?

> 3000000000L is bigger than INT_MAX.


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

* [Bug c/54743] Large loop runs endingless
  2012-09-29  5:44 [Bug c/54743] New: Large loop runs endingless slbyan at gmail dot com
                   ` (2 preceding siblings ...)
  2012-09-29  7:49 ` slbyan at gmail dot com
@ 2012-09-29  8:08 ` paolo.carlini at oracle dot com
  3 siblings, 0 replies; 5+ messages in thread
From: paolo.carlini at oracle dot com @ 2012-09-29  8:08 UTC (permalink / raw)
  To: gcc-bugs


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54743

--- Comment #4 from Paolo Carlini <paolo.carlini at oracle dot com> 2012-09-29 08:08:32 UTC ---
The condition is always to true thus the signed integer overflows and anything
can happen, maybe something different for different release series or at the
different optimization levels, anything really.


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

end of thread, other threads:[~2012-09-29  8:08 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-09-29  5:44 [Bug c/54743] New: Large loop runs endingless slbyan at gmail dot com
2012-09-29  7:25 ` [Bug c/54743] " schwab@linux-m68k.org
2012-09-29  7:48 ` slbyan at gmail dot com
2012-09-29  7:49 ` slbyan at gmail dot com
2012-09-29  8:08 ` paolo.carlini at oracle dot com

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