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

--- Comment #3 from Jonathan Wakely <redi at gcc dot gnu.org> ---
(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.

Reply via email to