public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/40752] -Wconversion generates false warnings for operands not larger than target type
[not found] <bug-40752-4@http.gcc.gnu.org/bugzilla/>
@ 2011-09-25 21:55 ` manu at gcc dot gnu.org
2012-03-24 20:21 ` manu at gcc dot gnu.org
` (6 subsequent siblings)
7 siblings, 0 replies; 13+ messages in thread
From: manu at gcc dot gnu.org @ 2011-09-25 21:55 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40752
Manuel López-Ibáñez <manu at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |ebrahim at mohammadi dot ir
--- Comment #19 from Manuel López-Ibáñez <manu at gcc dot gnu.org> 2011-09-25 21:12:33 UTC ---
*** Bug 50519 has been marked as a duplicate of this bug. ***
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug c++/40752] -Wconversion generates false warnings for operands not larger than target type
[not found] <bug-40752-4@http.gcc.gnu.org/bugzilla/>
2011-09-25 21:55 ` [Bug c++/40752] -Wconversion generates false warnings for operands not larger than target type manu at gcc dot gnu.org
@ 2012-03-24 20:21 ` manu at gcc dot gnu.org
2012-03-24 21:40 ` DeusExSophismata at gmail dot com
` (5 subsequent siblings)
7 siblings, 0 replies; 13+ messages in thread
From: manu at gcc dot gnu.org @ 2012-03-24 20:21 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40752
Manuel López-Ibáñez <manu at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |DeusExSophismata at gmail
| |dot com
--- Comment #20 from Manuel López-Ibáñez <manu at gcc dot gnu.org> 2012-03-24 19:27:54 UTC ---
*** Bug 52703 has been marked as a duplicate of this bug. ***
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug c++/40752] -Wconversion generates false warnings for operands not larger than target type
[not found] <bug-40752-4@http.gcc.gnu.org/bugzilla/>
2011-09-25 21:55 ` [Bug c++/40752] -Wconversion generates false warnings for operands not larger than target type manu at gcc dot gnu.org
2012-03-24 20:21 ` manu at gcc dot gnu.org
@ 2012-03-24 21:40 ` DeusExSophismata at gmail dot com
2012-05-05 15:31 ` wessjunk at gmail dot com
` (4 subsequent siblings)
7 siblings, 0 replies; 13+ messages in thread
From: DeusExSophismata at gmail dot com @ 2012-03-24 21:40 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40752
--- Comment #21 from David Stone <DeusExSophismata at gmail dot com> 2012-03-24 21:25:08 UTC ---
Why was this patch rejected, and is there a way to improve it so that obviously
safe cases (such as PR52703) are not warned about without having to specify a
'-Wno-' option?
Yes, according to the standard (C++03 5/9), calculations done on variables
smaller than int are first promoted to int, then the calculation is done, then
the value is converted back to the target size. However, C++03 1.8/3, the
"as-if rule", states that it the program can't tell the difference, you can do
whatever you want (see my answer to a similar question on Stack Overflow here:
http://stackoverflow.com/questions/5563000/implicit-type-conversion-rules-in-c-operators/8935697#8935697).
The C++ standard does not require a diagnostic for this, and the apparent
behavior is identical. Therefore, there can be no appeals to the C++ standard
on the behavior of the warning.
Because this is a purely option warning for which gcc defines the rules, we
should define it to be useful. If gcc can prove that all of the values are
greater than 0 (for instance, if all of the values are unsigned prior to
implicit promotion or are positive integral constant expressions), then there
is no possibility of having a negative value. Thanks to signed integer overflow
being undefined, there is no risk of creating a negative value that way,
either. Therefore, we should not warn. Having to manually say "Turn off stuff
that no one could ever possibly want to see" seems like a sure way to make this
warning useless.
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug c++/40752] -Wconversion generates false warnings for operands not larger than target type
[not found] <bug-40752-4@http.gcc.gnu.org/bugzilla/>
` (2 preceding siblings ...)
2012-03-24 21:40 ` DeusExSophismata at gmail dot com
@ 2012-05-05 15:31 ` wessjunk at gmail dot com
2012-05-05 16:05 ` manu at gcc dot gnu.org
` (3 subsequent siblings)
7 siblings, 0 replies; 13+ messages in thread
From: wessjunk at gmail dot com @ 2012-05-05 15:31 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40752
Wes <wessjunk at gmail dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |wessjunk at gmail dot com
--- Comment #22 from Wes <wessjunk at gmail dot com> 2012-05-05 15:09:22 UTC ---
I agree with David. My code has many instances of things like
a+=2
where a is a char and this makes -Wconversion useless to me.
It's too bad, since it would really be helpful as I am in the process of
changing some data types in the code.
If someone really thinks there should be a warning for this behavior, how about
adding a separate
-Wchar-arithmetic
warning which warns on all char arithmetic and see how much people use it.
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug c++/40752] -Wconversion generates false warnings for operands not larger than target type
[not found] <bug-40752-4@http.gcc.gnu.org/bugzilla/>
` (3 preceding siblings ...)
2012-05-05 15:31 ` wessjunk at gmail dot com
@ 2012-05-05 16:05 ` manu at gcc dot gnu.org
2012-06-20 14:59 ` dichlofos-mv at yandex dot ru
` (2 subsequent siblings)
7 siblings, 0 replies; 13+ messages in thread
From: manu at gcc dot gnu.org @ 2012-05-05 16:05 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40752
--- Comment #23 from Manuel López-Ibáñez <manu at gcc dot gnu.org> 2012-05-05 15:30:06 UTC ---
(In reply to comment #22)
> If someone really thinks there should be a warning for this behavior, how about
> adding a separate
> -Wchar-arithmetic
> warning which warns on all char arithmetic and see how much people use it.
I think adding a new option Wconversion-after-promotion that covers all cases
where the conversion occurs to the same type that was originally promoted from
would be the most appropriate. I have a feeling that it should not be hard to
implement, but I am not sure how, and I have many other things I would like to
do first. So, please David, Wes, photon, give it a try. The code is in
c-family/c-common.c (conversion_warning).
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug c++/40752] -Wconversion generates false warnings for operands not larger than target type
[not found] <bug-40752-4@http.gcc.gnu.org/bugzilla/>
` (4 preceding siblings ...)
2012-05-05 16:05 ` manu at gcc dot gnu.org
@ 2012-06-20 14:59 ` dichlofos-mv at yandex dot ru
2014-02-10 1:14 ` chengniansun at gmail dot com
2014-09-16 21:07 ` hariharan.gcc at gmail dot com
7 siblings, 0 replies; 13+ messages in thread
From: dichlofos-mv at yandex dot ru @ 2012-06-20 14:59 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40752
Mikhail Veltishchev <dichlofos-mv at yandex dot ru> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |dichlofos-mv at yandex dot
| |ru
--- Comment #24 from Mikhail Veltishchev <dichlofos-mv at yandex dot ru> 2012-06-20 14:57:31 UTC ---
Well, please fix this. My cases are instructions like
unsigned short x = 100;
unsigned short y = 200;
// gives a warning
x += y;
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug c++/40752] -Wconversion generates false warnings for operands not larger than target type
[not found] <bug-40752-4@http.gcc.gnu.org/bugzilla/>
` (5 preceding siblings ...)
2012-06-20 14:59 ` dichlofos-mv at yandex dot ru
@ 2014-02-10 1:14 ` chengniansun at gmail dot com
2014-09-16 21:07 ` hariharan.gcc at gmail dot com
7 siblings, 0 replies; 13+ messages in thread
From: chengniansun at gmail dot com @ 2014-02-10 1:14 UTC (permalink / raw)
To: gcc-bugs
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset="UTF-8", Size: 2897 bytes --]
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40752
--- Comment #25 from Chengnian Sun <chengniansun at gmail dot com> ---
Today I encountered a similar case as follows. The conversion warning by gcc is
not true as right-shifting an unsigned short decreases the value.
BTW clang does not emit warnings for this code snippet.
$: cat s1.c
unsigned short fn(unsigned short a, int right) {
return a >> right;
}
$: gcc-trunk -c -Wconversion s1.c
s1.c: In function âfnâ:
s1.c:2:3: warning: conversion to âshort unsigned intâ from âintâ may alter its
value [-Wconversion]
return a >> right;
^
$: clang-trunk -c -Wconversion s1.c
$:
>From gcc-bugs-return-443154-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Mon Feb 10 01:28:47 2014
Return-Path: <gcc-bugs-return-443154-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org>
Delivered-To: listarch-gcc-bugs@gcc.gnu.org
Received: (qmail 15230 invoked by alias); 10 Feb 2014 01:28:47 -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 15198 invoked by uid 48); 10 Feb 2014 01:28:43 -0000
From: "dartmetrash at gmail dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c++/60113] Internal compiler error
Date: Mon, 10 Feb 2014 01:28: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.6.3
X-Bugzilla-Keywords:
X-Bugzilla-Severity: normal
X-Bugzilla-Who: dartmetrash at gmail dot com
X-Bugzilla-Status: WAITING
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: attachments.created
Message-ID: <bug-60113-4-qIPcKsoEnk@http.gcc.gnu.org/bugzilla/>
In-Reply-To: <bug-60113-4@http.gcc.gnu.org/bugzilla/>
References: <bug-60113-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-02/txt/msg00911.txt.bz2
Content-length: 461
http://gcc.gnu.org/bugzilla/show_bug.cgi?id`113
--- Comment #2 from lmat <dartmetrash at gmail dot com> ---
Created attachment 32090
--> http://gcc.gnu.org/bugzilla/attachment.cgi?id2090&actioníit
Bug report including command line output.
My apologies! I was quite sure I had attached it, but I see quite plainly that
I had failed! It appears that my upload was too big. I've divided it up using
split --lines 35000 ...
which creates three files.
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug c++/40752] -Wconversion generates false warnings for operands not larger than target type
[not found] <bug-40752-4@http.gcc.gnu.org/bugzilla/>
` (6 preceding siblings ...)
2014-02-10 1:14 ` chengniansun at gmail dot com
@ 2014-09-16 21:07 ` hariharan.gcc at gmail dot com
7 siblings, 0 replies; 13+ messages in thread
From: hariharan.gcc at gmail dot com @ 2014-09-16 21:07 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=40752
hariharan.gcc at gmail dot com changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |hariharan.gcc at gmail dot com
--- Comment #27 from hariharan.gcc at gmail dot com ---
I encountered a similar problem with -Wconversion. This option is useless if it
would warn for cases like
short int i;
i += 5;
I concede Andrew's point about this being technically a place to warn, but in
practice, i would like for it to warn only when the target is a "smaller" than
any of the inputs.
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug c++/40752] -Wconversion generates false warnings for operands not larger than target type
2009-07-14 19:17 [Bug c++/40752] New: -Wconversion generates false warnings photon at seznam dot cz
` (3 preceding siblings ...)
2010-06-11 20:22 ` manu at gcc dot gnu dot org
@ 2010-06-12 16:46 ` photon at seznam dot cz
4 siblings, 0 replies; 13+ messages in thread
From: photon at seznam dot cz @ 2010-06-12 16:46 UTC (permalink / raw)
To: gcc-bugs
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 540 bytes --]
------- Comment #18 from photon at seznam dot cz 2010-06-12 16:46 -------
(In reply to comment #17)
> The patch was rejected but it may be accepted by using a new -Wno-* option to
> disable these warnings. Perhaps -Wno-conversion-after-promotion?
>
> Suggestions are welcome.
>
-Wconversion should be fixed to work as specified. No warning should be
generated for the following code:
char c = 2;
// warning: conversion to char from int may alter its value
c >>= 1;
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40752
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug c++/40752] -Wconversion generates false warnings for operands not larger than target type
2009-07-14 19:17 [Bug c++/40752] New: -Wconversion generates false warnings photon at seznam dot cz
` (2 preceding siblings ...)
2009-09-05 14:05 ` manu at gcc dot gnu dot org
@ 2010-06-11 20:22 ` manu at gcc dot gnu dot org
2010-06-12 16:46 ` photon at seznam dot cz
4 siblings, 0 replies; 13+ messages in thread
From: manu at gcc dot gnu dot org @ 2010-06-11 20:22 UTC (permalink / raw)
To: gcc-bugs
------- Comment #17 from manu at gcc dot gnu dot org 2010-06-11 20:22 -------
The patch was rejected but it may be accepted by using a new -Wno-* option to
disable these warnings. Perhaps -Wno-conversion-after-promotion?
Suggestions are welcome.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40752
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug c++/40752] -Wconversion generates false warnings for operands not larger than target type
2009-07-14 19:17 [Bug c++/40752] New: -Wconversion generates false warnings photon at seznam dot cz
2009-07-16 7:07 ` [Bug c++/40752] -Wconversion generates false warnings for operands not larger than target type photon at seznam dot cz
2009-07-23 15:35 ` manu at gcc dot gnu dot org
@ 2009-09-05 14:05 ` manu at gcc dot gnu dot org
2010-06-11 20:22 ` manu at gcc dot gnu dot org
2010-06-12 16:46 ` photon at seznam dot cz
4 siblings, 0 replies; 13+ messages in thread
From: manu at gcc dot gnu dot org @ 2009-09-05 14:05 UTC (permalink / raw)
To: gcc-bugs
------- Comment #16 from manu at gcc dot gnu dot org 2009-09-05 14:05 -------
*** Bug 41274 has been marked as a duplicate of this bug. ***
--
manu at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |ashaduri at gmail dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40752
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug c++/40752] -Wconversion generates false warnings for operands not larger than target type
2009-07-14 19:17 [Bug c++/40752] New: -Wconversion generates false warnings photon at seznam dot cz
2009-07-16 7:07 ` [Bug c++/40752] -Wconversion generates false warnings for operands not larger than target type photon at seznam dot cz
@ 2009-07-23 15:35 ` manu at gcc dot gnu dot org
2009-09-05 14:05 ` manu at gcc dot gnu dot org
` (2 subsequent siblings)
4 siblings, 0 replies; 13+ messages in thread
From: manu at gcc dot gnu dot org @ 2009-07-23 15:35 UTC (permalink / raw)
To: gcc-bugs
------- Comment #15 from manu at gcc dot gnu dot org 2009-07-23 15:35 -------
Patch: http://gcc.gnu.org/ml/gcc-patches/2009-07/msg01179.html
--
manu at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
URL| |http://gcc.gnu.org/ml/gcc-
| |patches/2009-
| |07/msg01179.html
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40752
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug c++/40752] -Wconversion generates false warnings for operands not larger than target type
2009-07-14 19:17 [Bug c++/40752] New: -Wconversion generates false warnings photon at seznam dot cz
@ 2009-07-16 7:07 ` photon at seznam dot cz
2009-07-23 15:35 ` manu at gcc dot gnu dot org
` (3 subsequent siblings)
4 siblings, 0 replies; 13+ messages in thread
From: photon at seznam dot cz @ 2009-07-16 7:07 UTC (permalink / raw)
To: gcc-bugs
--
photon at seznam dot cz changed:
What |Removed |Added
----------------------------------------------------------------------------
Severity|enhancement |normal
Summary|-Wconversion: do not warn |-Wconversion generates false
|for operands not larger than|warnings for operands not
|target type |larger than target type
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40752
^ permalink raw reply [flat|nested] 13+ messages in thread
end of thread, other threads:[~2014-09-16 21:07 UTC | newest]
Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
[not found] <bug-40752-4@http.gcc.gnu.org/bugzilla/>
2011-09-25 21:55 ` [Bug c++/40752] -Wconversion generates false warnings for operands not larger than target type manu at gcc dot gnu.org
2012-03-24 20:21 ` manu at gcc dot gnu.org
2012-03-24 21:40 ` DeusExSophismata at gmail dot com
2012-05-05 15:31 ` wessjunk at gmail dot com
2012-05-05 16:05 ` manu at gcc dot gnu.org
2012-06-20 14:59 ` dichlofos-mv at yandex dot ru
2014-02-10 1:14 ` chengniansun at gmail dot com
2014-09-16 21:07 ` hariharan.gcc at gmail dot com
2009-07-14 19:17 [Bug c++/40752] New: -Wconversion generates false warnings photon at seznam dot cz
2009-07-16 7:07 ` [Bug c++/40752] -Wconversion generates false warnings for operands not larger than target type photon at seznam dot cz
2009-07-23 15:35 ` manu at gcc dot gnu dot org
2009-09-05 14:05 ` manu at gcc dot gnu dot org
2010-06-11 20:22 ` manu at gcc dot gnu dot org
2010-06-12 16:46 ` photon at seznam dot cz
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).