public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/59846] New: Imprecise column number for -Wtype-limits
@ 2014-01-16 18:13 chengniansun at gmail dot com
2014-01-23 13:20 ` [Bug c/59846] " mpolacek at gcc dot gnu.org
` (3 more replies)
0 siblings, 4 replies; 5+ messages in thread
From: chengniansun at gmail dot com @ 2014-01-16 18:13 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59846
Bug ID: 59846
Summary: Imprecise column number for -Wtype-limits
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
GCC outputs a wrong column number of a type-limit (comparison between 0 and
unsigned) warning.
$ gcc-trunk -Wall -Wextra -c -std=c11 -pedantic s.c
s.c: In function ‘fn1’:
s.c:33:3: warning: comparison is always false due to limited range of data type
[-Wtype-limits]
return b ^= ( b < (0UL > p));
^
$ clang-trunk -Wall -Wextra -c -std=c11 -pedantic s.c
s.c:33:38: warning: comparison of 0 > unsigned expression is always false
[-Wtautological-compare]
return b ^= ( b < (0UL > p));
~~~ ^ ~
1 warning generated.
$ cat s.c
int fn1(unsigned p) {
int b = 99;
return b ^= ( b < (0UL > p));
}
>From gcc-bugs-return-440596-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Thu Jan 16 18:18:18 2014
Return-Path: <gcc-bugs-return-440596-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org>
Delivered-To: listarch-gcc-bugs@gcc.gnu.org
Received: (qmail 8363 invoked by alias); 16 Jan 2014 18:18:18 -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 7973 invoked by uid 48); 16 Jan 2014 18:18:13 -0000
From: "jason at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c++/59821] __builtin_LINE and __builtin_FILE for new'd objects is wrong
Date: Thu, 16 Jan 2014 18:18: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: 4.8.2
X-Bugzilla-Keywords: wrong-debug
X-Bugzilla-Severity: normal
X-Bugzilla-Who: jason at gcc dot gnu.org
X-Bugzilla-Status: NEW
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-59821-4-HOmKhrefxJ@http.gcc.gnu.org/bugzilla/>
In-Reply-To: <bug-59821-4@http.gcc.gnu.org/bugzilla/>
References: <bug-59821-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/msg01738.txt.bz2
Content-length: 626
http://gcc.gnu.org/bugzilla/show_bug.cgi?idY821
--- Comment #6 from Jason Merrill <jason at gcc dot gnu.org> ---
(In reply to Jakub Jelinek from comment #4)
> While I agree with that, for _builtin_{LINE,FILE,FUNCTION} (), those were
> added specifically for the use in default arguments and were I think from
> the start meant to give you the location of the call, not of the token where
> it appears, otherwise those builtins don't make much sense (you could use
> __LINE__, __FILE__ or __FUNCTION__ instead).
Ah, I see. In that case, I agree that adjusting their locations in
break_out_target_exprs is the way to go.
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug c/59846] Imprecise column number for -Wtype-limits
2014-01-16 18:13 [Bug c/59846] New: Imprecise column number for -Wtype-limits chengniansun at gmail dot com
@ 2014-01-23 13:20 ` mpolacek at gcc dot gnu.org
2014-01-23 14:26 ` mpolacek at gcc dot gnu.org
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2014-01-23 13:20 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59846
Marek Polacek <mpolacek at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Last reconfirmed| |2014-01-23
CC| |mpolacek at gcc dot gnu.org
Ever confirmed|0 |1
--- Comment #1 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
Confirmed.
Extended testcase (locus is imprecise), use -Wlogical-op -Wtype-limits.
_Bool
fn1 (unsigned int p)
{
return 0UL > p;
}
_Bool
fn2 (unsigned int p)
{
return 0UL <= p;
}
_Bool
fn3 (unsigned int p)
{
return p >= 0U;
}
_Bool
fn4 (unsigned int p)
{
return p < 0U;
}
_Bool
fn5 (_Bool p)
{
return p || !p;
}
_Bool
fn6 (_Bool p)
{
return p && !p;
}
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug c/59846] Imprecise column number for -Wtype-limits
2014-01-16 18:13 [Bug c/59846] New: Imprecise column number for -Wtype-limits chengniansun at gmail dot com
2014-01-23 13:20 ` [Bug c/59846] " mpolacek at gcc dot gnu.org
@ 2014-01-23 14:26 ` mpolacek at gcc dot gnu.org
2014-01-23 21:01 ` mpolacek at gcc dot gnu.org
2014-01-23 21:03 ` mpolacek at gcc dot gnu.org
3 siblings, 0 replies; 5+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2014-01-23 14:26 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59846
Marek Polacek <mpolacek at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |ASSIGNED
Assignee|unassigned at gcc dot gnu.org |mpolacek at gcc dot gnu.org
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug c/59846] Imprecise column number for -Wtype-limits
2014-01-16 18:13 [Bug c/59846] New: Imprecise column number for -Wtype-limits chengniansun at gmail dot com
2014-01-23 13:20 ` [Bug c/59846] " mpolacek at gcc dot gnu.org
2014-01-23 14:26 ` mpolacek at gcc dot gnu.org
@ 2014-01-23 21:01 ` mpolacek at gcc dot gnu.org
2014-01-23 21:03 ` mpolacek at gcc dot gnu.org
3 siblings, 0 replies; 5+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2014-01-23 21:01 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59846
--- Comment #2 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
Author: mpolacek
Date: Thu Jan 23 21:01:08 2014
New Revision: 207008
URL: http://gcc.gnu.org/viewcvs?rev=207008&root=gcc&view=rev
Log:
PR c/59846
c-family/
* c-common.c (shorten_compare): Add location_t parameter.
* c-common.h (shorten_binary_op): Adjust declaration.
cp/
* typeck.c (cp_build_binary_op): Pass location to shorten_compare.
c/
* c-typeck.c (parser_build_binary_op): Use location instead of
input_location.
(build_binary_op): Pass location to shorten_compare.
testsuite/
* gcc.dg/pr59846.c: New test.
Added:
trunk/gcc/testsuite/gcc.dg/pr59846.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/typeck.c
trunk/gcc/testsuite/ChangeLog
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug c/59846] Imprecise column number for -Wtype-limits
2014-01-16 18:13 [Bug c/59846] New: Imprecise column number for -Wtype-limits chengniansun at gmail dot com
` (2 preceding siblings ...)
2014-01-23 21:01 ` mpolacek at gcc dot gnu.org
@ 2014-01-23 21:03 ` mpolacek at gcc dot gnu.org
3 siblings, 0 replies; 5+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2014-01-23 21:03 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59846
Marek Polacek <mpolacek at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|ASSIGNED |RESOLVED
Resolution|--- |FIXED
Target Milestone|--- |4.9.0
--- Comment #3 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
Fixed.
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2014-01-23 21:03 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-01-16 18:13 [Bug c/59846] New: Imprecise column number for -Wtype-limits chengniansun at gmail dot com
2014-01-23 13:20 ` [Bug c/59846] " mpolacek at gcc dot gnu.org
2014-01-23 14:26 ` mpolacek at gcc dot gnu.org
2014-01-23 21:01 ` mpolacek at gcc dot gnu.org
2014-01-23 21:03 ` 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).