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 20:34:00 -0000	[thread overview]
Message-ID: <20090310203423.1072.qmail@sourceware.org> (raw)
In-Reply-To: <bug-39170-17296@http.gcc.gnu.org/bugzilla/>



------- Comment #6 from tom at atoptech dot com  2009-03-10 20:34 -------
Subject: Re:  cannot silence -Wconversion warnings for
        bit-fields


> AFAIK, that is not true. I just tried your very example with gcc 4.2.4 and it
> doesn't warn with -Wall -Wextra -Wconversion. g++ did warn but not with -Wall,
> you still needed to specify -Wconversion, and it did not warn in many cases. So
> please, check your facts.

You are correct in 4.2 you still need the -Wconversion option. We
upgraded from 3.4.6 to 4.2/4.3. In 3.4.6, gcc warned of this error
without any additional options.

> Fixing bugs alters behaviour. The change of behaviour was documented 
> beyond what is normally expected.

You are splitting hairs. I don't see this change as a bug-fix. It's
along the lines to reinterpreting the "C" or "C++" language with regard
to bit-field assignments. The only way "C" or "C++" to assign a integral
variable a bit field is an assignment:

   struct A
   {
      unsigned int v : 2;
   }

   void foo( A * a, int v ) { a->v = v; }

For which "gcc" now issues an warning for, always! And there is no
"language" defined way to eliminate this warning. Outside of writing
something ugly like:

 struct A
 {
    union {
       unsigned int v : 2;
       unsigned int fill;
    };
  };

  void foo( A * a, int v )
  {
    a->fill |= v & 0x3;
  }

And if I have to write this, I might as well not use a bit-field!

Again, gcc 4.3.x now issues thousands of warnings (in our code) for
which we have NO reasonable and portable way to clean the code and NO
way to suppress the warning.

It makes the compiler (for us) not usable.

> Of course it doesn't. Have you understood what -Wtraditional-converion (and the
> old -Wconversion) actually warned for?

I don't care what "-Wconversion" previously did. We never used it, we
did not need to! In 3.4.6 the compiler issued the implicit conversion
warnings without additional options. In 4.2/4.3 you need -Wconversion to
get these warnings. In 4.2.4, "gcc" doesn't warn about bit-fields, but
in 4.3.x it does.

> Really? Then I have no ideas. In any case, someone else would need to 
> take care of this because I do not have time. >
> http://gcc.gnu.org/faq.html#support

I don't understand why this change was made when "C" and the "C++"
language has no support for it... 

Given this has not been been an issue with "C" for over 30 years, there
is probably a reason it is not in the language.


-- 


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


  parent reply	other threads:[~2009-03-10 20:34 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
2009-03-10 19:16 ` manu at gcc dot gnu dot org
2009-03-10 20:34 ` tom at atoptech dot com [this message]
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=20090310203423.1072.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).