https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98572
--- Comment #2 from Chun Feng <vonchun at gmail dot com> --- Hi Pinskia: Thanks for looking into this. This is my understanding: As rules from https://wiki.sei.cmu.edu/confluence/display/c/INT02-C.+Understand+integer+conversion+rules 1. If both operands have the same type, no further conversion is needed. 2. If both operands are of the same integer type (signed or unsigned), the operand with the type of lesser integer conversion rank is converted to the type of the operand with greater rank. 3. If the operand that has unsigned integer type has rank greater than or equal to the rank of the type of the other operand, the operand with signed integer type is converted to the type of the operand with unsigned integer type. 4. If the type of the operand with signed integer type can represent all of the values of the type of the operand with unsigned integer type, the operand with unsigned integer type is converted to the type of the operand with signed integer type. 5. Otherwise, both operands are converted to the unsigned integer type corresponding to the type of the operand with signed integer type. Rule 2 should be applied over rule 4 (the assumption here is 12 is interpreted as unsigned int rather than int) p = t1.bits24 << 12; BTW, I tried Visual Studio compiler, it doesn't do signed extension as gcc. On Wed, Jan 6, 2021 at 10:59 AM pinskia at gcc dot gnu.org < gcc-bugzi...@gcc.gnu.org> wrote: > https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98572 > > --- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> --- > >Even if integer promotion happens, it should be promoted as "unsigned > int" as well. > > > Why do you think it should be promoted to unsigned int rather int? Since a > 24bit unsigned int fits into a 32 bit singed int, int is used first. > > -- > You are receiving this mail because: > You reported the bug.