public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/59940] New: Imprecise column number for -Wconversion
@ 2014-01-25 4:24 chengniansun at gmail dot com
2014-01-26 12:59 ` [Bug c/59940] " mpolacek at gcc dot gnu.org
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: chengniansun at gmail dot com @ 2014-01-25 4:24 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59940
Bug ID: 59940
Summary: Imprecise column number for -Wconversion
Product: gcc
Version: 4.9.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c
Assignee: unassigned at gcc dot gnu.org
Reporter: chengniansun at gmail dot com
The column numbers of conversion warnings are not precise.
$: cat s.c
int f(unsigned i);
int g(int i) {
return f(i) + f(i)
+ f(i);
}
$: gcc-trunk -c -Wconversion s.c
s.c: In function ‘g’:
s.c:4:1: warning: conversion to ‘unsigned int’ from ‘int’ may change the sign
of the result [-Wsign-conversion]
return f(i) + f(i)
^
s.c:4:1: warning: conversion to ‘unsigned int’ from ‘int’ may change the sign
of the result [-Wsign-conversion]
s.c:5:19: warning: conversion to ‘unsigned int’ from ‘int’ may change the sign
of the result [-Wsign-conversion]
+ f(i);
^
$: clang-trunk -c -Wconversion s.c
s.c:4:16: warning: implicit conversion changes signedness: 'int' to 'unsigned
int' [-Wsign-conversion]
return f(i) + f(i)
~ ^
s.c:4:23: warning: implicit conversion changes signedness: 'int' to 'unsigned
int' [-Wsign-conversion]
return f(i) + f(i)
~ ^
s.c:5:23: warning: implicit conversion changes signedness: 'int' to 'unsigned
int' [-Wsign-conversion]
+ f(i);
~ ^
3 warnings generated.
$: gcc-trunk -v
Using built-in specs.
COLLECT_GCC=gcc-trunk
COLLECT_LTO_WRAPPER=/home/chengniansun/tools/gcc-trunk-binaries/libexec/gcc/x86_64-unknown-linux-gnu/4.9.0/lto-wrapper
Target: x86_64-unknown-linux-gnu
Configured with: ../gcc-trunk/configure --enable-languages=c,c++
--disable-multilib --prefix=/home/chengniansun/tools/gcc-trunk-binaries :
(reconfigured) ../gcc-trunk/configure --enable-languages=c,c++
--disable-multilib --prefix=/home/chengniansun/tools/gcc-trunk-binaries
Thread model: posix
gcc version 4.9.0 20140123 (experimental) (GCC)
>From gcc-bugs-return-441515-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Sat Jan 25 05:01:58 2014
Return-Path: <gcc-bugs-return-441515-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org>
Delivered-To: listarch-gcc-bugs@gcc.gnu.org
Received: (qmail 31614 invoked by alias); 25 Jan 2014 05:01: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 31567 invoked by uid 48); 25 Jan 2014 05:01:52 -0000
From: "law at redhat dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug bootstrap/59934] Bootstrap fail since r206941: expmed.h:252:33: error: array subscript is above array bounds
Date: Sat, 25 Jan 2014 05:01:00 -0000
X-Bugzilla-Reason: CC
X-Bugzilla-Type: changed
X-Bugzilla-Watch-Reason: None
X-Bugzilla-Product: gcc
X-Bugzilla-Component: bootstrap
X-Bugzilla-Version: 4.9.0
X-Bugzilla-Keywords:
X-Bugzilla-Severity: major
X-Bugzilla-Who: law at redhat dot com
X-Bugzilla-Status: ASSIGNED
X-Bugzilla-Priority: P2
X-Bugzilla-Assigned-To: law at redhat dot com
X-Bugzilla-Target-Milestone: ---
X-Bugzilla-Flags:
X-Bugzilla-Changed-Fields: bug_status cf_reconfirmed_on everconfirmed
Message-ID: <bug-59934-4-dRIijXISQy@http.gcc.gnu.org/bugzilla/>
In-Reply-To: <bug-59934-4@http.gcc.gnu.org/bugzilla/>
References: <bug-59934-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-01/txt/msg02657.txt.bz2
Content-length: 1067
http://gcc.gnu.org/bugzilla/show_bug.cgi?idY934
Jeffrey A. Law <law at redhat dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |ASSIGNED
Last reconfirmed| |2014-01-25
Ever confirmed|0 |1
--- Comment #11 from Jeffrey A. Law <law at redhat dot com> ---
The amount of overhead is, umm, so little to be in the noise.
We end up turning one arithmetic & return/branch into 3 immediate loads and a
call on a path that's so cold it should never matter.
Your solution returns a bogus value for those conditions. That should never
happen, but if it does, returning a value that may then be mis-interpreted/used
by the caller just seems like a problem waiting to happen.
WRT --disable-checking making the warning come back, that's easy enough to fix.
Instead of gcc_assert, we just do make it look like an old fashioned abort:
if (cant_happen)
abort ();
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug c/59940] Imprecise column number for -Wconversion
2014-01-25 4:24 [Bug c/59940] New: Imprecise column number for -Wconversion chengniansun at gmail dot com
@ 2014-01-26 12:59 ` mpolacek at gcc dot gnu.org
2014-01-30 16:16 ` mpolacek at gcc dot gnu.org
2014-01-30 16:19 ` mpolacek at gcc dot gnu.org
2 siblings, 0 replies; 4+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2014-01-26 12:59 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59940
Marek Polacek <mpolacek at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |ASSIGNED
Last reconfirmed| |2014-01-26
CC| |mpolacek at gcc dot gnu.org
Assignee|unassigned at gcc dot gnu.org |mpolacek at gcc dot gnu.org
Target Milestone|--- |4.9.0
Ever confirmed|0 |1
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug c/59940] Imprecise column number for -Wconversion
2014-01-25 4:24 [Bug c/59940] New: Imprecise column number for -Wconversion chengniansun at gmail dot com
2014-01-26 12:59 ` [Bug c/59940] " mpolacek at gcc dot gnu.org
@ 2014-01-30 16:16 ` mpolacek at gcc dot gnu.org
2014-01-30 16:19 ` mpolacek at gcc dot gnu.org
2 siblings, 0 replies; 4+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2014-01-30 16:16 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59940
--- Comment #1 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
Author: mpolacek
Date: Thu Jan 30 16:15:36 2014
New Revision: 207309
URL: http://gcc.gnu.org/viewcvs?rev=207309&root=gcc&view=rev
Log:
PR c/59940
c-family/
* c-common.h (unsafe_conversion_p): Adjust declaration.
(warnings_for_convert_and_check): Likewise.
(convert_and_check): Likewise.
* c-common.c (unsafe_conversion_p): Add location parameter. Call
expansion_point_location_if_in_system_header on it.
(warnings_for_convert_and_check): Add location parameter. Call
expansion_point_location_if_in_system_header on it. Use it.
(convert_and_check): Add location parameter. Use it.
(conversion_warning): Likewise.
(c_add_case_label): Adjust convert_and_check calls.
(scalar_to_vector): Adjust unsafe_conversion_p calls.
cp/
* typeck.c (build_ptrmemfunc1): Call convert_and_check with
input_location.
* cvt.c (cp_convert_and_check): Call warnings_for_convert_and_check
with input_location.
* call.c (build_conditional_expr_1): Call unsafe_conversion_p with
loc parameter.
c/
* c-typeck.c (build_function_call_vec): Use loc parameter.
(convert_arguments): Add location parameter. Use it.
(ep_convert_and_check): Likewise.
(build_atomic_assign): Adjust convert_for_assignment call.
(build_modify_expr): Likewise.
(digest_init): Likewise.
(c_finish_return): Likewise.
(build_conditional_expr): Adjust ep_convert_and_check calls.
(convert_for_assignment): Add rhs_loc parameter. Use it.
(build_binary_op): Adjust convert_and_check and ep_convert_and_check
calls.
testsuite/
* gcc.dg/pr59940.c: New test.
* gcc.dg/pr35635.c (func3): Move dg-warning.
Added:
trunk/gcc/testsuite/gcc.dg/pr59940.c
Modified:
trunk/gcc/c-family/ChangeLog
trunk/gcc/c-family/c-common.c
trunk/gcc/c-family/c-common.h
trunk/gcc/c/ChangeLog
trunk/gcc/c/c-typeck.c
trunk/gcc/cp/ChangeLog
trunk/gcc/cp/call.c
trunk/gcc/cp/cvt.c
trunk/gcc/cp/typeck.c
trunk/gcc/testsuite/ChangeLog
trunk/gcc/testsuite/gcc.dg/pr35635.c
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug c/59940] Imprecise column number for -Wconversion
2014-01-25 4:24 [Bug c/59940] New: Imprecise column number for -Wconversion chengniansun at gmail dot com
2014-01-26 12:59 ` [Bug c/59940] " mpolacek at gcc dot gnu.org
2014-01-30 16:16 ` mpolacek at gcc dot gnu.org
@ 2014-01-30 16:19 ` mpolacek at gcc dot gnu.org
2 siblings, 0 replies; 4+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2014-01-30 16:19 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59940
Marek Polacek <mpolacek at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|ASSIGNED |RESOLVED
Resolution|--- |FIXED
--- Comment #2 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
I'm marking this as FIXED, but the PR59963 fix will bring some more
improvements.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2014-01-30 16:19 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-01-25 4:24 [Bug c/59940] New: Imprecise column number for -Wconversion chengniansun at gmail dot com
2014-01-26 12:59 ` [Bug c/59940] " mpolacek at gcc dot gnu.org
2014-01-30 16:16 ` mpolacek at gcc dot gnu.org
2014-01-30 16:19 ` 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).