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] cannot silence -Wconversion warnings for bit-fields
Date: Tue, 10 Mar 2009 17:40:00 -0000	[thread overview]
Message-ID: <20090310174013.2703.qmail@sourceware.org> (raw)
In-Reply-To: <bug-39170-17296@http.gcc.gnu.org/bugzilla/>



------- Comment #4 from tom at atoptech dot com  2009-03-10 17:40 -------
Manuel,

You miss understood what I meant by "old behavior was just fine". I was saying
that the previous behavior of "gcc" worked fine and I was NOT referring
specifically to the "-Wconversion" option. 

The previous version of "gcc" warned when implicit narrowing of doubles to
integral values, such as

    double n = 0.0000000005;
    int d = n;

when using the "-Wall" option. 

The behavior of "gcc" has changed. Moving all the conversion warnings to fall
under "-Wconversion" may make semantic sense, but it alters the behavior of
"gcc". 

We can fault ourselves for missing this change in the documentation, but there
a level of expectation that the fundamental behavior of the compiler is
consistent from release-to-release. And when fundamental behavior of "gcc"
changes, ample notice should be given. People need to change Makefiles, alter
code (if possible), etc... 

With regard to "-Wtraditional-conversion", it does not work when compiling
"C++" code.

> Do you think this would be an acceptable solution? (I don't know if this works
> now in GCC 4.4)

Absolutely not. It's not a portable solution. There is nothing in the "C++"
standard (that I'm aware of) that suggests that "anding" an integral value with
a "constant" value results in a truncated integral value. It's a bad hack.

As you say, its is unfortunate that "C" and "C++" do not have a bit-field
"cast-operators". But that is the reality. 

There is a lot of code written using "bit-fields". Look at "gcc" itself. Until
the "C" or "C++" language contains a "type-safe" construct, such as a
cast-operator, "gcc" should not issue a warning by default.

If you have ideas on how to solve this, please submit them to the "C" or "C++"
standards group.

The "gcc" 4.3 stream is not safe (for us) to use as is. We need the compiler to
issue warnings when implicit narrowing occurs (expect in the case of a
bit-field). As is, we get thousands of warnings from our code when using
"-Wconversion". Consequently, we are forced disable "-Wconversion" to suppress
the bit-field warnings at the risk of missing other narrowing warnings. And
this is not acceptable to us.

We've already moved back to the 4.2 "gcc".

Best Regards,

Tom Geocaris


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39170


  parent reply	other threads:[~2009-03-10 17:40 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-02-12 17:34 [Bug c++/39170] New: -Wconversion useless 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
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 [this message]
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=20090310174013.2703.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).