public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/40733] New: No warning is issued when an implicit conversion can lead to a data loss
@ 2009-07-13 15:53 photon at seznam dot cz
2009-07-13 15:56 ` [Bug c++/40733] " pinskia at gcc dot gnu dot org
` (9 more replies)
0 siblings, 10 replies; 11+ messages in thread
From: photon at seznam dot cz @ 2009-07-13 15:53 UTC (permalink / raw)
To: gcc-bugs
The following code contains an implicit integer conversion involving a data
loss. There is no warning issued even when -Wall is specified.
int main()
{
int i = 0x12345678;
char c = i; // No warning is issued here
}
--
Summary: No warning is issued when an implicit conversion can
lead to a data loss
Product: gcc
Version: 4.4.0
Status: UNCONFIRMED
Severity: enhancement
Priority: P3
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: photon at seznam dot cz
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40733
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug c++/40733] No warning is issued when an implicit conversion can lead to a data loss
2009-07-13 15:53 [Bug c++/40733] New: No warning is issued when an implicit conversion can lead to a data loss photon at seznam dot cz
@ 2009-07-13 15:56 ` pinskia at gcc dot gnu dot org
2009-07-13 20:57 ` photon at seznam dot cz
` (8 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2009-07-13 15:56 UTC (permalink / raw)
To: gcc-bugs
------- Comment #1 from pinskia at gcc dot gnu dot org 2009-07-13 15:56 -------
-Wconversion needs to be supplied.
--
pinskia at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
Resolution| |WORKSFORME
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40733
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug c++/40733] No warning is issued when an implicit conversion can lead to a data loss
2009-07-13 15:53 [Bug c++/40733] New: No warning is issued when an implicit conversion can lead to a data loss photon at seznam dot cz
2009-07-13 15:56 ` [Bug c++/40733] " pinskia at gcc dot gnu dot org
@ 2009-07-13 20:57 ` photon at seznam dot cz
2009-07-13 21:42 ` pinskia at gcc dot gnu dot org
` (7 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: photon at seznam dot cz @ 2009-07-13 20:57 UTC (permalink / raw)
To: gcc-bugs
------- Comment #2 from photon at seznam dot cz 2009-07-13 20:57 -------
-Wall has a very misleading name and should probably be changed to match the
MSC behaviour (enable all warnings available).
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40733
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug c++/40733] No warning is issued when an implicit conversion can lead to a data loss
2009-07-13 15:53 [Bug c++/40733] New: No warning is issued when an implicit conversion can lead to a data loss photon at seznam dot cz
2009-07-13 15:56 ` [Bug c++/40733] " pinskia at gcc dot gnu dot org
2009-07-13 20:57 ` photon at seznam dot cz
@ 2009-07-13 21:42 ` pinskia at gcc dot gnu dot org
2009-07-14 8:37 ` photon at seznam dot cz
` (6 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2009-07-13 21:42 UTC (permalink / raw)
To: gcc-bugs
------- Comment #3 from pinskia at gcc dot gnu dot org 2009-07-13 21:42 -------
(In reply to comment #2)
> -Wall has a very misleading name and should probably be changed to match the
> MSC behaviour (enable all warnings available).
"-Wall
This enables all the warnings about constructions that some users consider
questionable, and that are easy to avoid (or modify to prevent the warning),
even in conjunction with macros. "
hmm, I don't know a better name for -Wall really. Since it enables all
warnings that are questionable and easy to avoid. implicit integer conversion
is easy to avoid but is used all the place in normal C/C++ code. and with
integer promotion happening with simple stuff like a + b, some folks will have
a hard time to understand that happens which is why it is not enabled with
-Wall.
Plus there are style warnings not included in -Wall. I really doubt you want
style warnings enabled with -Wall :).
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40733
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug c++/40733] No warning is issued when an implicit conversion can lead to a data loss
2009-07-13 15:53 [Bug c++/40733] New: No warning is issued when an implicit conversion can lead to a data loss photon at seznam dot cz
` (2 preceding siblings ...)
2009-07-13 21:42 ` pinskia at gcc dot gnu dot org
@ 2009-07-14 8:37 ` photon at seznam dot cz
2009-07-14 9:25 ` jakub at gcc dot gnu dot org
` (5 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: photon at seznam dot cz @ 2009-07-14 8:37 UTC (permalink / raw)
To: gcc-bugs
------- Comment #4 from photon at seznam dot cz 2009-07-14 08:37 -------
(In reply to comment #3)
> and with integer promotion happening with simple stuff like a + b,
> some folks will have a hard time to understand that happens which
> is why it is not enabled with -Wall.
The warning is issued only for rare conversions involving a potential data loss
which should always be explicit.
>
> Plus there are style warnings not included in -Wall. I really doubt you want
> style warnings enabled with -Wall :).
>
-Wall should be a real -Wall. Now it does not include important warnings like
those generated by -Wconversion (potential implicit data loss).
GCC should use numerical warning levels. The current -Wall should be renamed
to, e.g., -W3 and the new -Wall option should enable all warnings as the name
says.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40733
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug c++/40733] No warning is issued when an implicit conversion can lead to a data loss
2009-07-13 15:53 [Bug c++/40733] New: No warning is issued when an implicit conversion can lead to a data loss photon at seznam dot cz
` (3 preceding siblings ...)
2009-07-14 8:37 ` photon at seznam dot cz
@ 2009-07-14 9:25 ` jakub at gcc dot gnu dot org
2009-07-14 14:04 ` manu at gcc dot gnu dot org
` (4 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: jakub at gcc dot gnu dot org @ 2009-07-14 9:25 UTC (permalink / raw)
To: gcc-bugs
------- Comment #5 from jakub at gcc dot gnu dot org 2009-07-14 09:24 -------
-Wconversion hits extremely often, it is definitely not a warning that can or
should be enabled in -Wall, nor in -W.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40733
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug c++/40733] No warning is issued when an implicit conversion can lead to a data loss
2009-07-13 15:53 [Bug c++/40733] New: No warning is issued when an implicit conversion can lead to a data loss photon at seznam dot cz
` (4 preceding siblings ...)
2009-07-14 9:25 ` jakub at gcc dot gnu dot org
@ 2009-07-14 14:04 ` manu at gcc dot gnu dot org
2009-07-14 15:14 ` photon at seznam dot cz
` (3 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: manu at gcc dot gnu dot org @ 2009-07-14 14:04 UTC (permalink / raw)
To: gcc-bugs
------- Comment #6 from manu at gcc dot gnu dot org 2009-07-14 14:04 -------
There is a FAQ for the new Wconversion:
http://gcc.gnu.org/wiki/NewWconversion#faq
It should answer users' concerns.
As for Wall, we have users requesting less warnings from Wall and users
requesting more. We try to find a balance. But you are free to suggest that
existing warnings be moved to Wall or Wextra. However, first try compiling a
few big projects (like the kernel, QT libraries and KDE) and check that the
suggested warning only finds real bugs. Thanks.
--
manu at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |manu at gcc dot gnu dot org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40733
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug c++/40733] No warning is issued when an implicit conversion can lead to a data loss
2009-07-13 15:53 [Bug c++/40733] New: No warning is issued when an implicit conversion can lead to a data loss photon at seznam dot cz
` (5 preceding siblings ...)
2009-07-14 14:04 ` manu at gcc dot gnu dot org
@ 2009-07-14 15:14 ` photon at seznam dot cz
2009-07-14 15:31 ` photon at seznam dot cz
` (2 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: photon at seznam dot cz @ 2009-07-14 15:14 UTC (permalink / raw)
To: gcc-bugs
------- Comment #7 from photon at seznam dot cz 2009-07-14 15:13 -------
(In reply to comment #5)
> -Wconversion hits extremely often, it is definitely not a warning that can or
> should be enabled in -Wall, nor in -W.
>
The fact that "it hits often" should not be an argument against including it in
the warning level -Wall. Implicit conversion to a smaller type occurs
infrequently and should always be explicit to avoid hard to find bugs.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40733
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug c++/40733] No warning is issued when an implicit conversion can lead to a data loss
2009-07-13 15:53 [Bug c++/40733] New: No warning is issued when an implicit conversion can lead to a data loss photon at seznam dot cz
` (6 preceding siblings ...)
2009-07-14 15:14 ` photon at seznam dot cz
@ 2009-07-14 15:31 ` photon at seznam dot cz
2009-07-14 16:47 ` pinskia at gcc dot gnu dot org
2009-07-14 18:11 ` photon at seznam dot cz
9 siblings, 0 replies; 11+ messages in thread
From: photon at seznam dot cz @ 2009-07-14 15:31 UTC (permalink / raw)
To: gcc-bugs
------- Comment #8 from photon at seznam dot cz 2009-07-14 15:31 -------
(In reply to comment #6)
>
> As for Wall, we have users requesting less warnings from Wall and users
> requesting more. We try to find a balance. But you are free to suggest that
> existing warnings be moved to Wall or Wextra.
There should be no discussion about adding or removing anything from the -Wall
level. It should include all warnings available. The current -Wall should be
renamed to something like -W3 to prevent misleading users. Each warning should
be assigned a warning level depending on the severity. The user should normally
only need to specify the desired warning level. -Wall should be used only
occasionally to make sure no warning is missed.
> However, first try compiling a
> few big projects (like the kernel, QT libraries and KDE) and check that the
> suggested warning only finds real bugs. Thanks.
>
Are you suggesting that -Wconversion does not find real bugs?
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40733
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug c++/40733] No warning is issued when an implicit conversion can lead to a data loss
2009-07-13 15:53 [Bug c++/40733] New: No warning is issued when an implicit conversion can lead to a data loss photon at seznam dot cz
` (7 preceding siblings ...)
2009-07-14 15:31 ` photon at seznam dot cz
@ 2009-07-14 16:47 ` pinskia at gcc dot gnu dot org
2009-07-14 18:11 ` photon at seznam dot cz
9 siblings, 0 replies; 11+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2009-07-14 16:47 UTC (permalink / raw)
To: gcc-bugs
------- Comment #9 from pinskia at gcc dot gnu dot org 2009-07-14 16:47 -------
(In reply to comment #8)
> The current -Wall should be
> renamed to something like -W3 to prevent misleading users.
It only misleading users who don't read the documentation. The all part is
described in the documentation as:
"This enables all the warnings about constructions that some users consider
questionable, and that are easy to avoid (or modify to prevent the warning),
even in conjunction with macros. "
So the all is accurate in the sense it is all useful warnings; but it is not
all warnings.
Most folks don't want -Wformat-nonliteral and -Wformat-security in their
warning set. Or even -Wmissing-include-dirs or even -Winvalid-pch which will
warn if you have a PCH done for -O0 and one done for -O2 and you are compiling
at -O2 (and yes this happens all the time).
So your definition of -Wall is not very useful at all and will be even more
misleading to users or why the warnings are happening.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40733
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug c++/40733] No warning is issued when an implicit conversion can lead to a data loss
2009-07-13 15:53 [Bug c++/40733] New: No warning is issued when an implicit conversion can lead to a data loss photon at seznam dot cz
` (8 preceding siblings ...)
2009-07-14 16:47 ` pinskia at gcc dot gnu dot org
@ 2009-07-14 18:11 ` photon at seznam dot cz
9 siblings, 0 replies; 11+ messages in thread
From: photon at seznam dot cz @ 2009-07-14 18:11 UTC (permalink / raw)
To: gcc-bugs
------- Comment #10 from photon at seznam dot cz 2009-07-14 18:11 -------
(In reply to comment #9)
>
> So your definition of -Wall is not very useful at all and will be even more
> misleading to users or why the warnings are happening.
>
MSC's /Wall enables all warnings and I don't find it misleading at all.
http://msdn.microsoft.com/en-us/library/thxezb7y(VS.71).aspx
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40733
^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2009-07-14 18:11 UTC | newest]
Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-07-13 15:53 [Bug c++/40733] New: No warning is issued when an implicit conversion can lead to a data loss photon at seznam dot cz
2009-07-13 15:56 ` [Bug c++/40733] " pinskia at gcc dot gnu dot org
2009-07-13 20:57 ` photon at seznam dot cz
2009-07-13 21:42 ` pinskia at gcc dot gnu dot org
2009-07-14 8:37 ` photon at seznam dot cz
2009-07-14 9:25 ` jakub at gcc dot gnu dot org
2009-07-14 14:04 ` manu at gcc dot gnu dot org
2009-07-14 15:14 ` photon at seznam dot cz
2009-07-14 15:31 ` photon at seznam dot cz
2009-07-14 16:47 ` pinskia at gcc dot gnu dot org
2009-07-14 18:11 ` 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).