public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/52699] New: infinite loop generated with -O0
@ 2012-03-24  7:54 jarrydb at cse dot unsw.edu.au
  2012-03-24  7:55 ` [Bug c++/52699] " jarrydb at cse dot unsw.edu.au
                   ` (9 more replies)
  0 siblings, 10 replies; 11+ messages in thread
From: jarrydb at cse dot unsw.edu.au @ 2012-03-24  7:54 UTC (permalink / raw)
  To: gcc-bugs

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

             Bug #: 52699
           Summary: infinite loop generated with -O0
    Classification: Unclassified
           Product: gcc
           Version: 4.8.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: jarrydb@cse.unsw.edu.au


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

* [Bug c++/52699] infinite loop generated with -O0
  2012-03-24  7:54 [Bug c++/52699] New: infinite loop generated with -O0 jarrydb at cse dot unsw.edu.au
@ 2012-03-24  7:55 ` jarrydb at cse dot unsw.edu.au
  2012-03-24  7:56 ` jarrydb at cse dot unsw.edu.au
                   ` (8 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: jarrydb at cse dot unsw.edu.au @ 2012-03-24  7:55 UTC (permalink / raw)
  To: gcc-bugs

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

Jarryd Beck <jarrydb at cse dot unsw.edu.au> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Target|                            |i686-pc-linux-gnu
               Host|                            |i686-pc-linux-gnu
              Build|                            |i686-pc-linux-gnu

--- Comment #1 from Jarryd Beck <jarrydb at cse dot unsw.edu.au> 2012-03-24 07:54:23 UTC ---
When the attached file is compiled with no optimisation, the resulting program
never terminates.

  g++ -std=gnu++11 random.cpp

If I compile it with:

  g++ -std=gnu++11 random.cpp -O1

then it works.

The program is as follows, fully preprocessed sources are attached.

#include <random>

typedef std::mt19937::result_type unit_type;
typedef std::independent_bits_engine
<
  std::mt19937,
  sizeof(unit_type)*8,
  unit_type
> full_bits_generator;

int main()
{
  full_bits_generator gen;

  gen();
  return 0;
}

Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/home/jarryd/local/gcc-4.8/libexec/gcc/i686-pc-linux-gnu/4.8.0/lto-wrapper
Target: i686-pc-linux-gnu
Configured with: /home/jarryd/git/gcc-git/configure
--prefix=/home/jarryd/local/gcc-4.8 --disable-multilib --enable-languages=c,c++
Thread model: posix
gcc version 4.8.0 20120323 (experimental) (GCC)


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

* [Bug c++/52699] infinite loop generated with -O0
  2012-03-24  7:54 [Bug c++/52699] New: infinite loop generated with -O0 jarrydb at cse dot unsw.edu.au
  2012-03-24  7:55 ` [Bug c++/52699] " jarrydb at cse dot unsw.edu.au
@ 2012-03-24  7:56 ` jarrydb at cse dot unsw.edu.au
  2012-03-24  7:57 ` jarrydb at cse dot unsw.edu.au
                   ` (7 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: jarrydb at cse dot unsw.edu.au @ 2012-03-24  7:56 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from Jarryd Beck <jarrydb at cse dot unsw.edu.au> 2012-03-24 07:55:16 UTC ---
Created attachment 26972
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=26972
this file never terminates with -O0


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

* [Bug c++/52699] infinite loop generated with -O0
  2012-03-24  7:54 [Bug c++/52699] New: infinite loop generated with -O0 jarrydb at cse dot unsw.edu.au
  2012-03-24  7:55 ` [Bug c++/52699] " jarrydb at cse dot unsw.edu.au
  2012-03-24  7:56 ` jarrydb at cse dot unsw.edu.au
@ 2012-03-24  7:57 ` jarrydb at cse dot unsw.edu.au
  2012-03-24  8:07 ` jarrydb at cse dot unsw.edu.au
                   ` (6 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: jarrydb at cse dot unsw.edu.au @ 2012-03-24  7:57 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from Jarryd Beck <jarrydb at cse dot unsw.edu.au> 2012-03-24 07:56:15 UTC ---
Created attachment 26973
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=26973
The preprocessed version


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

* [Bug c++/52699] infinite loop generated with -O0
  2012-03-24  7:54 [Bug c++/52699] New: infinite loop generated with -O0 jarrydb at cse dot unsw.edu.au
                   ` (2 preceding siblings ...)
  2012-03-24  7:57 ` jarrydb at cse dot unsw.edu.au
@ 2012-03-24  8:07 ` jarrydb at cse dot unsw.edu.au
  2012-03-24  8:42 ` [Bug libstdc++/52699] " pinskia at gcc dot gnu.org
                   ` (5 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: jarrydb at cse dot unsw.edu.au @ 2012-03-24  8:07 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 from Jarryd Beck <jarrydb at cse dot unsw.edu.au> 2012-03-24 07:57:20 UTC ---
Note that this appears to happen only on 32 bit.


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

* [Bug libstdc++/52699] infinite loop generated with -O0
  2012-03-24  7:54 [Bug c++/52699] New: infinite loop generated with -O0 jarrydb at cse dot unsw.edu.au
                   ` (3 preceding siblings ...)
  2012-03-24  8:07 ` jarrydb at cse dot unsw.edu.au
@ 2012-03-24  8:42 ` pinskia at gcc dot gnu.org
  2012-04-12 12:53 ` paolo.carlini at oracle dot com
                   ` (4 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: pinskia at gcc dot gnu.org @ 2012-03-24  8:42 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
          Component|target                      |libstdc++

--- Comment #5 from Andrew Pinski <pinskia at gcc dot gnu.org> 2012-03-24 08:06:58 UTC ---
>From the looks of it, it looks more like a source (library) issue rather than a
compiler one.  Though I don't know enough of this code to say that.

We are stuck in the following loop:
754          result_type __u;
755          do
756            __u = _M_b() - _M_b.min();
757          while (__u >= __y0);

__y0 is 0 which means the loop is always true.


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

* [Bug libstdc++/52699] infinite loop generated with -O0
  2012-03-24  7:54 [Bug c++/52699] New: infinite loop generated with -O0 jarrydb at cse dot unsw.edu.au
                   ` (4 preceding siblings ...)
  2012-03-24  8:42 ` [Bug libstdc++/52699] " pinskia at gcc dot gnu.org
@ 2012-04-12 12:53 ` paolo.carlini at oracle dot com
  2012-04-12 13:10 ` paolo.carlini at oracle dot com
                   ` (3 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: paolo.carlini at oracle dot com @ 2012-04-12 12:53 UTC (permalink / raw)
  To: gcc-bugs

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

Paolo Carlini <paolo.carlini at oracle dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |ASSIGNED
   Last reconfirmed|                            |2012-04-12
         AssignedTo|unassigned at gcc dot       |paolo.carlini at oracle dot
                   |gnu.org                     |com
   Target Milestone|---                         |4.7.1
     Ever Confirmed|0                           |1

--- Comment #6 from Paolo Carlini <paolo.carlini at oracle dot com> 2012-04-12 12:52:50 UTC ---
Looks like something is wrong in the operator()() code vs 26.5.4.3.


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

* [Bug libstdc++/52699] infinite loop generated with -O0
  2012-03-24  7:54 [Bug c++/52699] New: infinite loop generated with -O0 jarrydb at cse dot unsw.edu.au
                   ` (5 preceding siblings ...)
  2012-04-12 12:53 ` paolo.carlini at oracle dot com
@ 2012-04-12 13:10 ` paolo.carlini at oracle dot com
  2012-04-14 22:34 ` paolo at gcc dot gnu.org
                   ` (2 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: paolo.carlini at oracle dot com @ 2012-04-12 13:10 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #7 from Paolo Carlini <paolo.carlini at oracle dot com> 2012-04-12 13:09:39 UTC ---
And the problem seems pretty clear: we have computations like:

      __s0 = result_type(1) << __w0;

with __w0 which can be 32, result_type 32 bits, thus definitely we aren't
handling a mathematical 2^32, as we should per 26.5.4.3. A fix should be
relatively easy.


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

* [Bug libstdc++/52699] infinite loop generated with -O0
  2012-03-24  7:54 [Bug c++/52699] New: infinite loop generated with -O0 jarrydb at cse dot unsw.edu.au
                   ` (6 preceding siblings ...)
  2012-04-12 13:10 ` paolo.carlini at oracle dot com
@ 2012-04-14 22:34 ` paolo at gcc dot gnu.org
  2012-04-15  2:15 ` paolo at gcc dot gnu.org
  2012-04-15  2:15 ` paolo.carlini at oracle dot com
  9 siblings, 0 replies; 11+ messages in thread
From: paolo at gcc dot gnu.org @ 2012-04-14 22:34 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #8 from paolo at gcc dot gnu.org <paolo at gcc dot gnu.org> 2012-04-14 22:33:27 UTC ---
Author: paolo
Date: Sat Apr 14 22:33:22 2012
New Revision: 186456

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=186456
Log:
2012-04-14  Paolo Carlini  <paolo.carlini@oracle.com>

    PR libstdc++/52699
    * include/bits/random.tcc (independent_bits_engine<>::operator()())
    Avoid various overflows; use common_type on result_type and
    _RandomNumberEngine::result_type; avoid floating point computations;
    other smaller tweaks.

    * include/bits/random.tcc (uniform_int_distribution<>::operator())
    Use common_type; assume _UniformRandomNumberGenerator::result_type
    unsigned; tidy.

    * include/bits/stl_algobase.h (__lg(unsigned), __lg(unsigned long),
    __lg(unsigned long long)): Add.

Modified:
    trunk/libstdc++-v3/ChangeLog
    trunk/libstdc++-v3/include/bits/random.tcc
    trunk/libstdc++-v3/include/bits/stl_algobase.h


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

* [Bug libstdc++/52699] infinite loop generated with -O0
  2012-03-24  7:54 [Bug c++/52699] New: infinite loop generated with -O0 jarrydb at cse dot unsw.edu.au
                   ` (7 preceding siblings ...)
  2012-04-14 22:34 ` paolo at gcc dot gnu.org
@ 2012-04-15  2:15 ` paolo at gcc dot gnu.org
  2012-04-15  2:15 ` paolo.carlini at oracle dot com
  9 siblings, 0 replies; 11+ messages in thread
From: paolo at gcc dot gnu.org @ 2012-04-15  2:15 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #9 from paolo at gcc dot gnu.org <paolo at gcc dot gnu.org> 2012-04-15 02:14:45 UTC ---
Author: paolo
Date: Sun Apr 15 02:14:39 2012
New Revision: 186461

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=186461
Log:
2012-04-14  Paolo Carlini  <paolo.carlini@oracle.com>

    PR libstdc++/52699
    * include/bits/random.tcc (independent_bits_engine<>::operator()())
    Avoid various overflows; use common_type on result_type and
    _RandomNumberEngine::result_type; avoid floating point computations;
    other smaller tweaks.

    * include/bits/random.tcc (uniform_int_distribution<>::operator())
    Use common_type; assume _UniformRandomNumberGenerator::result_type
    unsigned; tidy.

    * include/bits/stl_algobase.h (__lg(unsigned), __lg(unsigned long),
    __lg(unsigned long long)): Add.

Modified:
    branches/gcc-4_7-branch/libstdc++-v3/ChangeLog
    branches/gcc-4_7-branch/libstdc++-v3/include/bits/random.tcc
    branches/gcc-4_7-branch/libstdc++-v3/include/bits/stl_algobase.h


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

* [Bug libstdc++/52699] infinite loop generated with -O0
  2012-03-24  7:54 [Bug c++/52699] New: infinite loop generated with -O0 jarrydb at cse dot unsw.edu.au
                   ` (8 preceding siblings ...)
  2012-04-15  2:15 ` paolo at gcc dot gnu.org
@ 2012-04-15  2:15 ` paolo.carlini at oracle dot com
  9 siblings, 0 replies; 11+ messages in thread
From: paolo.carlini at oracle dot com @ 2012-04-15  2:15 UTC (permalink / raw)
  To: gcc-bugs

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

Paolo Carlini <paolo.carlini at oracle dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|                            |FIXED

--- Comment #10 from Paolo Carlini <paolo.carlini at oracle dot com> 2012-04-15 02:15:17 UTC ---
Fixed 4.7.1 and mainline.


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

end of thread, other threads:[~2012-04-15  2:15 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-03-24  7:54 [Bug c++/52699] New: infinite loop generated with -O0 jarrydb at cse dot unsw.edu.au
2012-03-24  7:55 ` [Bug c++/52699] " jarrydb at cse dot unsw.edu.au
2012-03-24  7:56 ` jarrydb at cse dot unsw.edu.au
2012-03-24  7:57 ` jarrydb at cse dot unsw.edu.au
2012-03-24  8:07 ` jarrydb at cse dot unsw.edu.au
2012-03-24  8:42 ` [Bug libstdc++/52699] " pinskia at gcc dot gnu.org
2012-04-12 12:53 ` paolo.carlini at oracle dot com
2012-04-12 13:10 ` paolo.carlini at oracle dot com
2012-04-14 22:34 ` paolo at gcc dot gnu.org
2012-04-15  2:15 ` paolo at gcc dot gnu.org
2012-04-15  2:15 ` 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).