public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/63886] New: float will fit into int with abs - possible missing warning Wabsolute-value
@ 2014-11-15 13:16 dcb314 at hotmail dot com
  2014-11-15 13:43 ` [Bug c/63886] " glisse at gcc dot gnu.org
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: dcb314 at hotmail dot com @ 2014-11-15 13:16 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 63886
           Summary: float will fit into int with abs - possible missing
                    warning Wabsolute-value
           Product: gcc
           Version: 5.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: dcb314 at hotmail dot com

# include <stdlib.h>

extern void g(int);

void f( float qw)
{
    int n = abs(qw);    

    g(n);
}

$ ~/gcc/results/bin/gcc -c -g -O2 -Wall -Wextra -pedantic nov15z.c
$ ~/gcc/results/bin/gcc -v
gcc version 5.0.0 20141112 (experimental) (GCC) 
$ ~/llvm/results/bin/clang -c -g -O2 -Wall nov15z.c
nov15z.c:10:10: warning: using integer absolute value function 'abs' when
      argument is of floating point type [-Wabsolute-value]
        int n = abs(qw);        
                ^


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

* [Bug c/63886] float will fit into int with abs - possible missing warning Wabsolute-value
  2014-11-15 13:16 [Bug c/63886] New: float will fit into int with abs - possible missing warning Wabsolute-value dcb314 at hotmail dot com
@ 2014-11-15 13:43 ` glisse at gcc dot gnu.org
  2015-01-07 15:43 ` mpolacek at gcc dot gnu.org
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: glisse at gcc dot gnu.org @ 2014-11-15 13:43 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #1 from Marc Glisse <glisse at gcc dot gnu.org> ---
warning: conversion to ‘int’ from ‘float’ may alter its value
[-Wfloat-conversion]
>From gcc-bugs-return-466854-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Sat Nov 15 13:49:57 2014
Return-Path: <gcc-bugs-return-466854-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org>
Delivered-To: listarch-gcc-bugs@gcc.gnu.org
Received: (qmail 10190 invoked by alias); 15 Nov 2014 13:49:57 -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 10161 invoked by uid 48); 15 Nov 2014 13:49:53 -0000
From: "dcb314 at hotmail dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c/63886] float will fit into int with abs - possible missing warning Wabsolute-value
Date: Sat, 15 Nov 2014 13:49: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-Version: 5.0
X-Bugzilla-Keywords:
X-Bugzilla-Severity: normal
X-Bugzilla-Who: dcb314 at hotmail 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-63886-4-XMxsAALHGl@http.gcc.gnu.org/bugzilla/>
In-Reply-To: <bug-63886-4@http.gcc.gnu.org/bugzilla/>
References: <bug-63886-4@http.gcc.gnu.org/bugzilla/>
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/
Auto-Submitted: auto-generated
MIME-Version: 1.0
X-SW-Source: 2014-11/txt/msg01326.txt.bz2
Content-length: 436

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

--- Comment #2 from David Binderman <dcb314 at hotmail dot com> ---
(In reply to Marc Glisse from comment #1)
> warning: conversion to ‘int’ from ‘float’ may alter its value
> [-Wfloat-conversion]

Thanks for that. 

Given the obscurity of -Wfloat-conversion, maybe it is time for it 
to be included in -Wall, where more folks will notice it ?
>From gcc-bugs-return-466855-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Sat Nov 15 14:15:42 2014
Return-Path: <gcc-bugs-return-466855-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org>
Delivered-To: listarch-gcc-bugs@gcc.gnu.org
Received: (qmail 19151 invoked by alias); 15 Nov 2014 14:15:42 -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 19120 invoked by uid 48); 15 Nov 2014 14:15:37 -0000
From: "dcb314 at hotmail dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c/63886] float will fit into int with abs - possible missing warning Wabsolute-value
Date: Sat, 15 Nov 2014 14:15: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-Version: 5.0
X-Bugzilla-Keywords:
X-Bugzilla-Severity: normal
X-Bugzilla-Who: dcb314 at hotmail 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-63886-4-gzkDWMMVRq@http.gcc.gnu.org/bugzilla/>
In-Reply-To: <bug-63886-4@http.gcc.gnu.org/bugzilla/>
References: <bug-63886-4@http.gcc.gnu.org/bugzilla/>
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/
Auto-Submitted: auto-generated
MIME-Version: 1.0
X-SW-Source: 2014-11/txt/msg01327.txt.bz2
Content-length: 723

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

--- Comment #3 from David Binderman <dcb314 at hotmail dot com> ---
(In reply to David Binderman from comment #2)
> Given the obscurity of -Wfloat-conversion, maybe it is time for it 
> to be included in -Wall, where more folks will notice it ?

Scratch that. While -Wfloat-conversion does check fine for
int into double, it also does the "whole lot less useful, even
though technically accurate" double into float message.

Like

float f = 3.1;

warning: conversion to ‘float’ alters ‘double’ constant value
[-Wfloat-conversion]

I'll proceed with -Wfloat-conversion, but I'll be stripping out
(fgrep -v) these unwanted warnings.
>From gcc-bugs-return-466856-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Sat Nov 15 14:20:48 2014
Return-Path: <gcc-bugs-return-466856-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org>
Delivered-To: listarch-gcc-bugs@gcc.gnu.org
Received: (qmail 24084 invoked by alias); 15 Nov 2014 14:20:48 -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 24051 invoked by uid 48); 15 Nov 2014 14:20:44 -0000
From: "redi at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c++/63887] New: abi_tag confuses demangler
Date: Sat, 15 Nov 2014 14:20:00 -0000
X-Bugzilla-Reason: CC
X-Bugzilla-Type: new
X-Bugzilla-Watch-Reason: None
X-Bugzilla-Product: gcc
X-Bugzilla-Component: c++
X-Bugzilla-Version: 5.0
X-Bugzilla-Keywords:
X-Bugzilla-Severity: normal
X-Bugzilla-Who: redi 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
Message-ID: <bug-63887-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-11/txt/msg01328.txt.bz2
Content-length: 722

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

            Bug ID: 63887
           Summary: abi_tag confuses demangler
           Product: gcc
           Version: 5.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: redi at gcc dot gnu.org
                CC: jason at gcc dot gnu.org

struct __attribute((abi_tag("cxx11"))) time_get
{
  ~time_get();
};

int main()
{
  time_get t;
}

/tmp/ccvqinyx.o: In function `main':
/tmp/t.cc:8: undefined reference to `time_get[abi:cxx11]::~cxx11()'
collect2: error: ld returned 1 exit status

Note that the destructor name is ~cxx11 not ~time_get


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

* [Bug c/63886] float will fit into int with abs - possible missing warning Wabsolute-value
  2014-11-15 13:16 [Bug c/63886] New: float will fit into int with abs - possible missing warning Wabsolute-value dcb314 at hotmail dot com
  2014-11-15 13:43 ` [Bug c/63886] " glisse at gcc dot gnu.org
@ 2015-01-07 15:43 ` mpolacek at gcc dot gnu.org
  2015-01-07 15:48 ` dcb314 at hotmail dot com
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2015-01-07 15:43 UTC (permalink / raw)
  To: gcc-bugs

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

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

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

--- Comment #5 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
Seems like there's nothing to do for this bug.


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

* [Bug c/63886] float will fit into int with abs - possible missing warning Wabsolute-value
  2014-11-15 13:16 [Bug c/63886] New: float will fit into int with abs - possible missing warning Wabsolute-value dcb314 at hotmail dot com
  2014-11-15 13:43 ` [Bug c/63886] " glisse at gcc dot gnu.org
  2015-01-07 15:43 ` mpolacek at gcc dot gnu.org
@ 2015-01-07 15:48 ` dcb314 at hotmail dot com
  2015-01-07 15:53 ` mpolacek at gcc dot gnu.org
  2015-01-20 20:25 ` egall at gwmail dot gwu.edu
  4 siblings, 0 replies; 6+ messages in thread
From: dcb314 at hotmail dot com @ 2015-01-07 15:48 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #6 from David Binderman <dcb314 at hotmail dot com> ---
(In reply to Marek Polacek from comment #5)
> Seems like there's nothing to do for this bug.

Suggest there are two cases

1. double to float

2. double or float into any integer type.

The one warning, produced by -Wfloat-conversion, could be
split into two warnings, as per the two cases.

#1 isn't very useful, #2 seems useful to me.

Then put case #1 into -Wall.


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

* [Bug c/63886] float will fit into int with abs - possible missing warning Wabsolute-value
  2014-11-15 13:16 [Bug c/63886] New: float will fit into int with abs - possible missing warning Wabsolute-value dcb314 at hotmail dot com
                   ` (2 preceding siblings ...)
  2015-01-07 15:48 ` dcb314 at hotmail dot com
@ 2015-01-07 15:53 ` mpolacek at gcc dot gnu.org
  2015-01-20 20:25 ` egall at gwmail dot gwu.edu
  4 siblings, 0 replies; 6+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2015-01-07 15:53 UTC (permalink / raw)
  To: gcc-bugs

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

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

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

--- Comment #7 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
Reopening then.


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

* [Bug c/63886] float will fit into int with abs - possible missing warning Wabsolute-value
  2014-11-15 13:16 [Bug c/63886] New: float will fit into int with abs - possible missing warning Wabsolute-value dcb314 at hotmail dot com
                   ` (3 preceding siblings ...)
  2015-01-07 15:53 ` mpolacek at gcc dot gnu.org
@ 2015-01-20 20:25 ` egall at gwmail dot gwu.edu
  4 siblings, 0 replies; 6+ messages in thread
From: egall at gwmail dot gwu.edu @ 2015-01-20 20:25 UTC (permalink / raw)
  To: gcc-bugs

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

Eric Gallager <egall at gwmail dot gwu.edu> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |egall at gwmail dot gwu.edu

--- Comment #8 from Eric Gallager <egall at gwmail dot gwu.edu> ---
(In reply to Andreas Schwab from comment #4)
> float f = 3.1f;

Isn't there already -Wunsuffixed-float-constants for warnings with that kind of
fix?


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

end of thread, other threads:[~2015-01-20 20:25 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-11-15 13:16 [Bug c/63886] New: float will fit into int with abs - possible missing warning Wabsolute-value dcb314 at hotmail dot com
2014-11-15 13:43 ` [Bug c/63886] " glisse at gcc dot gnu.org
2015-01-07 15:43 ` mpolacek at gcc dot gnu.org
2015-01-07 15:48 ` dcb314 at hotmail dot com
2015-01-07 15:53 ` mpolacek at gcc dot gnu.org
2015-01-20 20:25 ` egall at gwmail dot gwu.edu

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