public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "tom at atoptech dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c/39170] -Wconversion useless
Date: Thu, 12 Feb 2009 18:10:00 -0000 [thread overview]
Message-ID: <20090212181040.28331.qmail@sourceware.org> (raw)
In-Reply-To: <bug-39170-17296@http.gcc.gnu.org/bugzilla/>
------- Comment #2 from tom at atoptech dot com 2009-02-12 18:10 -------
Subject: Re: -Wconversion useless
You miss the point. The only way to assign a non-constant value to a bit
field outside of a struct is using an integral variable i.e.,
struct foo
{
int a : 2;
};
void assign( struct foo v, int x )
{
v.a = x;
}
This results automatically in a warning. How do code this assignment
type-safe? There is no (bit-field) cast operator in the C or C++.
Like the "gcc" code base, our code does a lot bit-field assignments. We
no get thousands of warning using -Wconversion, this behavior makes the
option useless.
Again, compile the "gcc" code-base with "-Wconversion" and then you will
understand the problem.
Expect for bit-fields which are problematic to do potential bit-loss
(you must use with caution), you want warnings for implicit narrowing if
values, e.g., (double -> int)
void foo( int x );
...
double n;
foo(n)
The old behavior was just fine!
I'm sure many people do not even realize they are NOT getting implicit
conversions warnings anymore because they are not caught by "-Wall"
anymore. We only discovered this be tracing a bug in our code! We then
turned on "-Wconversion" only to discover thousands of warnings with no
way practical way to fix them.
Regards,
Tom Geocaris
On Thu, 2009-02-12 at 17:39 +0000, pinskia at gcc dot gnu dot org wrote:
>
> ------- Comment #1 from pinskia at gcc dot gnu dot org 2009-02-12 17:39 -------
> Really -Wconversion is correct to warn about bit-fields because the conversion
> will lose bits.
>
>
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39170
next prev parent reply other threads:[~2009-02-12 18:10 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-02-12 17:34 [Bug c++/39170] New: " tom at atoptech dot com
2009-02-12 17:39 ` [Bug c/39170] " pinskia at gcc dot gnu dot org
2009-02-12 18:10 ` tom at atoptech dot com [this message]
2009-03-08 3:30 ` [Bug c/39170] cannot silence -Wconversion warnings for bit-fields manu at gcc dot gnu dot org
2009-03-10 17:40 ` tom at atoptech dot com
2009-03-10 19:16 ` manu at gcc dot gnu dot org
2009-03-10 20:34 ` tom at atoptech dot com
2010-01-13 13:40 ` faure at kde dot org
2010-02-18 20:50 ` Zachary_Deretsky at mentor dot com
2010-03-06 0:20 ` Zachary_Deretsky at mentor dot com
2010-03-06 1:37 ` jengliang at gmail dot com
2010-03-06 12:19 ` [Bug c/39170] provide an option to " manu at gcc dot gnu dot org
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20090212181040.28331.qmail@sourceware.org \
--to=gcc-bugzilla@gcc.gnu.org \
--cc=gcc-bugs@gcc.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).