public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/12963] Wrong and misleading warning encourages writing non-portable code
[not found] <bug-12963-1710@http.gcc.gnu.org/bugzilla/>
@ 2006-01-25 11:39 ` bagnara at cs dot unipr dot it
2006-01-25 12:21 ` pcarlini at suse dot de
` (4 subsequent siblings)
5 siblings, 0 replies; 6+ messages in thread
From: bagnara at cs dot unipr dot it @ 2006-01-25 11:39 UTC (permalink / raw)
To: gcc-bugs
------- Comment #19 from bagnara at cs dot unipr dot it 2006-01-25 11:39 -------
Just a small update. On one of our projects we have now thousands of warnings
on the test "x < 0" for the function below, when Type is instantiated to an
unsigned integral type:
template <typename Type>
inline Result
sgn_generic(const Type& x) {
if (x < 0)
return V_LT;
if (x > 0)
return V_GT;
return V_EQ;
}
The net result is that some of us started using "-w" or stopped paying
attention to warnings, and, as a consequence bugs are creeping in at a much
increased rate. Please, give us a way to at least turn off that warning.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=12963
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c/12963] Wrong and misleading warning encourages writing non-portable code
[not found] <bug-12963-1710@http.gcc.gnu.org/bugzilla/>
2006-01-25 11:39 ` [Bug c/12963] Wrong and misleading warning encourages writing non-portable code bagnara at cs dot unipr dot it
@ 2006-01-25 12:21 ` pcarlini at suse dot de
2007-02-06 13:48 ` manu at gcc dot gnu dot org
` (3 subsequent siblings)
5 siblings, 0 replies; 6+ messages in thread
From: pcarlini at suse dot de @ 2006-01-25 12:21 UTC (permalink / raw)
To: gcc-bugs
------- Comment #20 from pcarlini at suse dot de 2006-01-25 12:20 -------
(In reply to comment #19)
> Just a small update. On one of our projects we have now thousands of warnings
> on the test "x < 0" for the function below, when Type is instantiated to an
> unsigned integral type:
>
> template <typename Type>
> inline Result
> sgn_generic(const Type& x) {
> if (x < 0)
> return V_LT;
> if (x > 0)
> return V_GT;
> return V_EQ;
> }
A side remark, about a weird workaround I had to use in the past in the library
(yes the problem is real, I agree, not sure about the best solution, however).
Would boil down to something like (mosulo stupid typos ;)
if (x > 0)
return V_GT;
else if (x)
return V_LT;
return V_EQ;
Seems correct to me and doesn't incur in any warning.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=12963
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c/12963] Wrong and misleading warning encourages writing non-portable code
[not found] <bug-12963-1710@http.gcc.gnu.org/bugzilla/>
2006-01-25 11:39 ` [Bug c/12963] Wrong and misleading warning encourages writing non-portable code bagnara at cs dot unipr dot it
2006-01-25 12:21 ` pcarlini at suse dot de
@ 2007-02-06 13:48 ` manu at gcc dot gnu dot org
2007-05-20 20:33 ` manu at gcc dot gnu dot org
` (2 subsequent siblings)
5 siblings, 0 replies; 6+ messages in thread
From: manu at gcc dot gnu dot org @ 2007-02-06 13:48 UTC (permalink / raw)
To: gcc-bugs
------- Comment #21 from manu at gcc dot gnu dot org 2007-02-06 13:48 -------
Patch: http://gcc.gnu.org/ml/gcc-patches/2007-01/msg01933.html
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=12963
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c/12963] Wrong and misleading warning encourages writing non-portable code
[not found] <bug-12963-1710@http.gcc.gnu.org/bugzilla/>
` (2 preceding siblings ...)
2007-02-06 13:48 ` manu at gcc dot gnu dot org
@ 2007-05-20 20:33 ` manu at gcc dot gnu dot org
2007-05-20 20:51 ` manu at gcc dot gnu dot org
2007-05-26 3:13 ` pinskia at gcc dot gnu dot org
5 siblings, 0 replies; 6+ messages in thread
From: manu at gcc dot gnu dot org @ 2007-05-20 20:33 UTC (permalink / raw)
To: gcc-bugs
------- Comment #22 from manu at gcc dot gnu dot org 2007-05-20 21:31 -------
Subject: Bug 12963
Author: manu
Date: Sun May 20 20:29:55 2007
New Revision: 124875
URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=124875
Log:
2007-05-20 Manuel Lopez-Ibanez <manu@gcc.gnu.org>
PR middle-end/7651
PR c++/11856
PR c/12963
PR c/23587
PR other/29694
* c.opt (Wtype-limits): New.
* doc/invoke.texi (Wtype-limits): Document it.
(Wextra): Enabled by -Wextra.
* c-opts.c (c_common_post_options): Enabled by -Wextra.
* c-common.c (shorten_compare): Warn with Wtype-limits.
testsuite/
* gcc.dg/compare6.c: Replace Wall with Wtype-limits.
* gcc.dg/Wtype-limits.c: New.
* gcc.dg/Wtype-limits-Wextra.c: New.
* gcc.dg/Wtype-limits-no.c: New.
* g++.dg/warn/Wtype-limits.C: New.
* g++.dg/warn/Wtype-limits-Wextra.C: New.
* g++.dg/warn/Wtype-limits-no.C: New.
Added:
trunk/gcc/testsuite/g++.dg/warn/Wtype-limits-Wextra.C
trunk/gcc/testsuite/g++.dg/warn/Wtype-limits-no.C
trunk/gcc/testsuite/g++.dg/warn/Wtype-limits.C
trunk/gcc/testsuite/gcc.dg/Wtype-limits-Wextra.c
trunk/gcc/testsuite/gcc.dg/Wtype-limits-no.c
trunk/gcc/testsuite/gcc.dg/Wtype-limits.c
Modified:
trunk/gcc/ChangeLog
trunk/gcc/c-common.c
trunk/gcc/c-opts.c
trunk/gcc/c.opt
trunk/gcc/doc/invoke.texi
trunk/gcc/testsuite/ChangeLog
trunk/gcc/testsuite/gcc.dg/compare6.c
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=12963
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c/12963] Wrong and misleading warning encourages writing non-portable code
[not found] <bug-12963-1710@http.gcc.gnu.org/bugzilla/>
` (3 preceding siblings ...)
2007-05-20 20:33 ` manu at gcc dot gnu dot org
@ 2007-05-20 20:51 ` manu at gcc dot gnu dot org
2007-05-26 3:13 ` pinskia at gcc dot gnu dot org
5 siblings, 0 replies; 6+ messages in thread
From: manu at gcc dot gnu dot org @ 2007-05-20 20:51 UTC (permalink / raw)
To: gcc-bugs
------- Comment #23 from manu at gcc dot gnu dot org 2007-05-20 21:50 -------
The diverse warnings of the type "always true/false because of range of data
type" have been grouped under -Wtype-limits that is enabled by -Wextra (and not
by -Wall). The warning can be disabled by using -Wno-type-limits.
Thus, fixed in GCC 4.3.
--
manu at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
Resolution| |FIXED
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=12963
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c/12963] Wrong and misleading warning encourages writing non-portable code
[not found] <bug-12963-1710@http.gcc.gnu.org/bugzilla/>
` (4 preceding siblings ...)
2007-05-20 20:51 ` manu at gcc dot gnu dot org
@ 2007-05-26 3:13 ` pinskia at gcc dot gnu dot org
5 siblings, 0 replies; 6+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2007-05-26 3:13 UTC (permalink / raw)
To: gcc-bugs
--
pinskia at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Target Milestone|--- |4.3.0
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=12963
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2007-05-26 3:13 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
[not found] <bug-12963-1710@http.gcc.gnu.org/bugzilla/>
2006-01-25 11:39 ` [Bug c/12963] Wrong and misleading warning encourages writing non-portable code bagnara at cs dot unipr dot it
2006-01-25 12:21 ` pcarlini at suse dot de
2007-02-06 13:48 ` manu at gcc dot gnu dot org
2007-05-20 20:33 ` manu at gcc dot gnu dot org
2007-05-20 20:51 ` manu at gcc dot gnu dot org
2007-05-26 3:13 ` pinskia at gcc dot gnu dot 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).