public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/57066] New: std::logb(-inf) returns wrong value
@ 2013-04-25  7:01 bolero.murakami at gmail dot com
  2013-04-25  8:05 ` [Bug c++/57066] [4.7/4.8/4.9 Regression] " rguenth at gcc dot gnu.org
                   ` (9 more replies)
  0 siblings, 10 replies; 11+ messages in thread
From: bolero.murakami at gmail dot com @ 2013-04-25  7:01 UTC (permalink / raw)
  To: gcc-bugs


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

             Bug #: 57066
           Summary: std::logb(-inf) returns wrong value
    Classification: Unclassified
           Product: gcc
           Version: 4.8.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: bolero.murakami@gmail.com


auto inf = std::numeric_limits<double>::infinity();
std::cout << std::logb(-inf) << std::endl;

"-inf" is output.
it is wrong.

std::logb(-inf) should returns +inf.
> F.9.3.11 The logb functions
> - logb(±∞) returns +∞.
>From gcc-bugs-return-420917-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Thu Apr 25 07:08:12 2013
Return-Path: <gcc-bugs-return-420917-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org>
Delivered-To: listarch-gcc-bugs@gcc.gnu.org
Received: (qmail 23643 invoked by alias); 25 Apr 2013 07:08:12 -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 23600 invoked by uid 48); 25 Apr 2013 07:08:08 -0000
From: "glisse at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c++/57064] [clarification requested] Which overload with ref-qualifier should be called?
Date: Thu, 25 Apr 2013 07:08:00 -0000
X-Bugzilla-Reason: CC
X-Bugzilla-Type: changed
X-Bugzilla-Watch-Reason: None
X-Bugzilla-Product: gcc
X-Bugzilla-Component: c++
X-Bugzilla-Keywords:
X-Bugzilla-Severity: normal
X-Bugzilla-Who: glisse 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-Changed-Fields:
Message-ID: <bug-57064-4-h8BYVt4czf@http.gcc.gnu.org/bugzilla/>
In-Reply-To: <bug-57064-4@http.gcc.gnu.org/bugzilla/>
References: <bug-57064-4@http.gcc.gnu.org/bugzilla/>
X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/
Auto-Submitted: auto-generated
Content-Type: text/plain; charset="UTF-8"
MIME-Version: 1.0
X-SW-Source: 2013-04/txt/msg02062.txt.bz2
Content-length: 1062


http://gcc.gnu.org/bugzilla/show_bug.cgi?idW064

--- Comment #7 from Marc Glisse <glisse at gcc dot gnu.org> 2013-04-25 07:08:07 UTC ---
(In reply to comment #6)
> void f(A &&a)
> {
>     std::move(a).p();
> }
>
> _Z1fO1A:
>         .cfi_startproc
>         jmp     _ZNR1A1pEv@PLT  #
>         .cfi_endproc
>
> Then this looks like a bug in 4.8.1.

Indeed, I get s/R/O/ with 4.9.

> But then are we in agreement that a.p() in that function above should call the
> lvalue-ref overload?

Yes.

> It does make the feature sligthly less useful for me. It
> would require writing:
>
>     return std::move(std::move(std::move(std::move(QString("%1 %2 %3 %4")
>                                                    .arg(42))
>                                           .arg(47))
>                                .arg(-42))
>                      .arg(-47));

Why? You are not naming those return values, so they are still rvalues and will
use the && overload. (not sure why Qstring doesn't provide a mutating interface
for arg)


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

* [Bug c++/57066] [4.7/4.8/4.9 Regression] std::logb(-inf) returns wrong value
  2013-04-25  7:01 [Bug c++/57066] New: std::logb(-inf) returns wrong value bolero.murakami at gmail dot com
@ 2013-04-25  8:05 ` rguenth at gcc dot gnu.org
  2013-04-25  8:41 ` mpolacek at gcc dot gnu.org
                   ` (8 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: rguenth at gcc dot gnu.org @ 2013-04-25  8:05 UTC (permalink / raw)
  To: gcc-bugs


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

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
      Known to work|                            |4.1.3
           Keywords|                            |wrong-code
   Last reconfirmed|                            |2013-04-25
     Ever Confirmed|0                           |1
            Summary|std::logb(-inf) returns     |[4.7/4.8/4.9 Regression]
                   |wrong value                 |std::logb(-inf) returns
                   |                            |wrong value
   Target Milestone|---                         |4.7.4

--- Comment #1 from Richard Biener <rguenth at gcc dot gnu.org> 2013-04-25 08:05:04 UTC ---
/* Fold a call to builtin logb/ilogb.  */

static tree
fold_builtin_logb (location_t loc, tree arg, tree rettype)
{
...
      switch (value->cl)
      {
      case rvc_nan:
      case rvc_inf:
        /* If arg is Inf or NaN and we're logb, return it.  */
        if (TREE_CODE (rettype) == REAL_TYPE)
          return fold_convert_loc (loc, rettype, arg);

is wrong for -inf.  Folding introduced in 2007 thus a regression.


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

* [Bug c++/57066] [4.7/4.8/4.9 Regression] std::logb(-inf) returns wrong value
  2013-04-25  7:01 [Bug c++/57066] New: std::logb(-inf) returns wrong value bolero.murakami at gmail dot com
  2013-04-25  8:05 ` [Bug c++/57066] [4.7/4.8/4.9 Regression] " rguenth at gcc dot gnu.org
@ 2013-04-25  8:41 ` mpolacek at gcc dot gnu.org
  2013-04-25 10:26 ` [Bug tree-optimization/57066] " mpolacek at gcc dot gnu.org
                   ` (7 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2013-04-25  8:41 UTC (permalink / raw)
  To: gcc-bugs


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

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

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

--- Comment #2 from Marek Polacek <mpolacek at gcc dot gnu.org> 2013-04-25 08:41:28 UTC ---
Note that at least -O is needed + -std=c++11.  With -O0 it correctly prints
"inf".


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

* [Bug tree-optimization/57066] [4.7/4.8/4.9 Regression] std::logb(-inf) returns wrong value
  2013-04-25  7:01 [Bug c++/57066] New: std::logb(-inf) returns wrong value bolero.murakami at gmail dot com
  2013-04-25  8:05 ` [Bug c++/57066] [4.7/4.8/4.9 Regression] " rguenth at gcc dot gnu.org
  2013-04-25  8:41 ` mpolacek at gcc dot gnu.org
@ 2013-04-25 10:26 ` mpolacek at gcc dot gnu.org
  2013-04-25 11:47 ` mpolacek at gcc dot gnu.org
                   ` (6 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2013-04-25 10:26 UTC (permalink / raw)
  To: gcc-bugs


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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |ASSIGNED
          Component|c++                         |tree-optimization
         AssignedTo|unassigned at gcc dot       |mpolacek at gcc dot gnu.org
                   |gnu.org                     |

--- Comment #3 from Marek Polacek <mpolacek at gcc dot gnu.org> 2013-04-25 10:26:57 UTC ---
I may have a fix.


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

* [Bug tree-optimization/57066] [4.7/4.8/4.9 Regression] std::logb(-inf) returns wrong value
  2013-04-25  7:01 [Bug c++/57066] New: std::logb(-inf) returns wrong value bolero.murakami at gmail dot com
                   ` (2 preceding siblings ...)
  2013-04-25 10:26 ` [Bug tree-optimization/57066] " mpolacek at gcc dot gnu.org
@ 2013-04-25 11:47 ` mpolacek at gcc dot gnu.org
  2013-04-25 13:43 ` mpolacek at gcc dot gnu.org
                   ` (5 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2013-04-25 11:47 UTC (permalink / raw)
  To: gcc-bugs


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

--- Comment #4 from Marek Polacek <mpolacek at gcc dot gnu.org> 2013-04-25 11:47:34 UTC ---
I wonder if std::logb(-NaN) should also return +NaN.


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

* [Bug tree-optimization/57066] [4.7/4.8/4.9 Regression] std::logb(-inf) returns wrong value
  2013-04-25  7:01 [Bug c++/57066] New: std::logb(-inf) returns wrong value bolero.murakami at gmail dot com
                   ` (3 preceding siblings ...)
  2013-04-25 11:47 ` mpolacek at gcc dot gnu.org
@ 2013-04-25 13:43 ` mpolacek at gcc dot gnu.org
  2013-04-25 15:52 ` mpolacek at gcc dot gnu.org
                   ` (4 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2013-04-25 13:43 UTC (permalink / raw)
  To: gcc-bugs


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

--- Comment #5 from Marek Polacek <mpolacek at gcc dot gnu.org> 2013-04-25 13:43:39 UTC ---
(In reply to comment #4)
> I wonder if std::logb(-NaN) should also return +NaN.

It turned out that in NaN's case it doesn't matter.


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

* [Bug tree-optimization/57066] [4.7/4.8/4.9 Regression] std::logb(-inf) returns wrong value
  2013-04-25  7:01 [Bug c++/57066] New: std::logb(-inf) returns wrong value bolero.murakami at gmail dot com
                   ` (5 preceding siblings ...)
  2013-04-25 15:52 ` mpolacek at gcc dot gnu.org
@ 2013-04-25 15:52 ` mpolacek at gcc dot gnu.org
  2013-05-03  8:55 ` [Bug tree-optimization/57066] [4.7/4.8 " mpolacek at gcc dot gnu.org
                   ` (2 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2013-04-25 15:52 UTC (permalink / raw)
  To: gcc-bugs


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

--- Comment #6 from Marek Polacek <mpolacek at gcc dot gnu.org> 2013-04-25 15:52:16 UTC ---
Author: mpolacek
Date: Thu Apr 25 15:51:57 2013
New Revision: 198308

URL: http://gcc.gnu.org/viewcvs?rev=198308&root=gcc&view=rev
Log:
    PR tree-optimization/57066
        * builtins.c (fold_builtin_logb): Return +Inf for -Inf.

        * gcc.dg/torture/builtin-logb-1.c: Adjust testcase.


Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/builtins.c
    trunk/gcc/testsuite/ChangeLog
    trunk/gcc/testsuite/gcc.dg/torture/builtin-logb-1.c


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

* [Bug tree-optimization/57066] [4.7/4.8/4.9 Regression] std::logb(-inf) returns wrong value
  2013-04-25  7:01 [Bug c++/57066] New: std::logb(-inf) returns wrong value bolero.murakami at gmail dot com
                   ` (4 preceding siblings ...)
  2013-04-25 13:43 ` mpolacek at gcc dot gnu.org
@ 2013-04-25 15:52 ` mpolacek at gcc dot gnu.org
  2013-04-25 15:52 ` mpolacek at gcc dot gnu.org
                   ` (3 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2013-04-25 15:52 UTC (permalink / raw)
  To: gcc-bugs


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

--- Comment #7 from Marek Polacek <mpolacek at gcc dot gnu.org> 2013-04-25 15:52:45 UTC ---
Fixed on trunk so far, will backport to 4.7/4.8 later on.


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

* [Bug tree-optimization/57066] [4.7/4.8 Regression] std::logb(-inf) returns wrong value
  2013-04-25  7:01 [Bug c++/57066] New: std::logb(-inf) returns wrong value bolero.murakami at gmail dot com
                   ` (6 preceding siblings ...)
  2013-04-25 15:52 ` mpolacek at gcc dot gnu.org
@ 2013-05-03  8:55 ` mpolacek at gcc dot gnu.org
  2013-05-03  8:59 ` mpolacek at gcc dot gnu.org
  2013-05-03  8:59 ` mpolacek at gcc dot gnu.org
  9 siblings, 0 replies; 11+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2013-05-03  8:55 UTC (permalink / raw)
  To: gcc-bugs


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

--- Comment #8 from Marek Polacek <mpolacek at gcc dot gnu.org> 2013-05-03 08:55:26 UTC ---
Author: mpolacek
Date: Fri May  3 08:55:08 2013
New Revision: 198570

URL: http://gcc.gnu.org/viewcvs?rev=198570&root=gcc&view=rev
Log:
    PR tree-optimization/57066
        * builtins.c (fold_builtin_logb): Return +Inf for -Inf.

        * gcc.dg/torture/builtin-logb-1.c: Adjust testcase.


Modified:
    branches/gcc-4_8-branch/gcc/ChangeLog
    branches/gcc-4_8-branch/gcc/builtins.c
    branches/gcc-4_8-branch/gcc/testsuite/ChangeLog
    branches/gcc-4_8-branch/gcc/testsuite/gcc.dg/torture/builtin-logb-1.c


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

* [Bug tree-optimization/57066] [4.7/4.8 Regression] std::logb(-inf) returns wrong value
  2013-04-25  7:01 [Bug c++/57066] New: std::logb(-inf) returns wrong value bolero.murakami at gmail dot com
                   ` (8 preceding siblings ...)
  2013-05-03  8:59 ` mpolacek at gcc dot gnu.org
@ 2013-05-03  8:59 ` mpolacek at gcc dot gnu.org
  9 siblings, 0 replies; 11+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2013-05-03  8:59 UTC (permalink / raw)
  To: gcc-bugs


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

--- Comment #9 from Marek Polacek <mpolacek at gcc dot gnu.org> 2013-05-03 08:59:30 UTC ---
Author: mpolacek
Date: Fri May  3 08:59:14 2013
New Revision: 198571

URL: http://gcc.gnu.org/viewcvs?rev=198571&root=gcc&view=rev
Log:
    PR tree-optimization/57066
        * builtins.c (fold_builtin_logb): Return +Inf for -Inf.

        * gcc.dg/torture/builtin-logb-1.c: Adjust testcase.


Modified:
    branches/gcc-4_7-branch/gcc/ChangeLog
    branches/gcc-4_7-branch/gcc/builtins.c
    branches/gcc-4_7-branch/gcc/testsuite/ChangeLog
    branches/gcc-4_7-branch/gcc/testsuite/gcc.dg/torture/builtin-logb-1.c


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

* [Bug tree-optimization/57066] [4.7/4.8 Regression] std::logb(-inf) returns wrong value
  2013-04-25  7:01 [Bug c++/57066] New: std::logb(-inf) returns wrong value bolero.murakami at gmail dot com
                   ` (7 preceding siblings ...)
  2013-05-03  8:55 ` [Bug tree-optimization/57066] [4.7/4.8 " mpolacek at gcc dot gnu.org
@ 2013-05-03  8:59 ` mpolacek at gcc dot gnu.org
  2013-05-03  8:59 ` mpolacek at gcc dot gnu.org
  9 siblings, 0 replies; 11+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2013-05-03  8:59 UTC (permalink / raw)
  To: gcc-bugs


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

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

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

--- Comment #10 from Marek Polacek <mpolacek at gcc dot gnu.org> 2013-05-03 08:59:42 UTC ---
Fixed.


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

end of thread, other threads:[~2013-05-03  8:59 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-04-25  7:01 [Bug c++/57066] New: std::logb(-inf) returns wrong value bolero.murakami at gmail dot com
2013-04-25  8:05 ` [Bug c++/57066] [4.7/4.8/4.9 Regression] " rguenth at gcc dot gnu.org
2013-04-25  8:41 ` mpolacek at gcc dot gnu.org
2013-04-25 10:26 ` [Bug tree-optimization/57066] " mpolacek at gcc dot gnu.org
2013-04-25 11:47 ` mpolacek at gcc dot gnu.org
2013-04-25 13:43 ` mpolacek at gcc dot gnu.org
2013-04-25 15:52 ` mpolacek at gcc dot gnu.org
2013-04-25 15:52 ` mpolacek at gcc dot gnu.org
2013-05-03  8:55 ` [Bug tree-optimization/57066] [4.7/4.8 " mpolacek at gcc dot gnu.org
2013-05-03  8:59 ` mpolacek at gcc dot gnu.org
2013-05-03  8:59 ` mpolacek 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).