public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "jh718.park at samsung dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c++/94767] (unsigned bitfield) + (int) operation results in int, not unsigned int.
Date: Mon, 27 Apr 2020 10:03:24 +0000	[thread overview]
Message-ID: <bug-94767-4-kxdYpeUOyF@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-94767-4@http.gcc.gnu.org/bugzilla/>

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94767

jh718.park at samsung dot com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|WAITING                     |RESOLVED
         Resolution|---                         |INVALID

--- Comment #4 from jh718.park at samsung dot com ---
(In reply to Jonathan Wakely from comment #3)
> (In reply to jh718.park from comment #0)
> > For these variables below,
> > 
> > unsigned m_schemeEnd : 26;
> > unsigned m_userStart;
> > 
> > m_userStart == m_schemeEnd + 1
> > 
> > this comparison emits a compiler warning as below.
> > 
> > warning: comparison of integer expressions of different signedness:
> > ‘unsigned int’ and ‘int’ [-Wsign-compare]
> 
> Why do you think that's wrong?
> 
> In [conv.prom] p5 the standard says:
> 
> "A prvalue for an integral bit-field (11.4.9) can be converted to a prvalue
> of type int if int can represent all the values of the bit-field;"
> 
> Since int is wider than 26 bits it can represent all the values of
> m_schemeEnd, so the operands of 'm_schemeEnd + 1' are both promoted to int,
> and the result is an int.

Thank you for your comment, Jonathan.
I understand your point.

I thought that unsigned bitfield should be converted to unsigned
during usual arithmetic conversions without knowing the item,
http://eel.is/c++draft/conv.prom#5.

Then, I will mark this issue as resolved/invalid, and update the bug
https://bugs.webkit.org/show_bug.cgi?id=211044
with the comment you left here.

Thank you for your help:)

      parent reply	other threads:[~2020-04-27 10:03 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-04-26  2:08 [Bug c++/94767] New: " jh718.park at samsung dot com
2020-04-26  8:41 ` [Bug c++/94767] " pinskia at gcc dot gnu.org
2020-04-27  6:40 ` rguenth at gcc dot gnu.org
2020-04-27  8:36 ` redi at gcc dot gnu.org
2020-04-27 10:03 ` jh718.park at samsung dot com [this message]

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=bug-94767-4-kxdYpeUOyF@http.gcc.gnu.org/bugzilla/ \
    --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).