Re: [dev] [sbase] [patch v2] Add md5sum

From: sin <sin_AT_2f30.org>
Date: Wed, 19 Jun 2013 18:23:12 +0300

On Wed, Jun 19, 2013 at 04:47:02PM +0200, Szabolcs Nagy wrote:
> * sin <sin_AT_2f30.org> [2013-06-19 15:00:43 +0300]:
> > > Integer promotion rules are nasty! I think something like
> > > the following would still be ok?
> > >
> > > unsigned f(unsigned int c) { return c<<24U; }
> >
> > Although in this case we still have undefined behaviour
> > because unsigned int can be 2 bytes by the standard.
> >
> > Depending on the ABI this might or might not be an issue.
>
> don't worry about 2byte int, that does not work on linux
> (and posix platforms in general)
>
> bit shift does not do arithmetic conversion:
> the signedness of the right operand does not matter,
> integer promotion is applied independently to the two
> sides
>
> the usual way to do the char shift is
>
> (uint32_t)c<<24
>
> or
>
> uint32_t w = c;
> w << 24

Aha, I see - thanks :)
Received on Wed Jun 19 2013 - 17:23:12 CEST

This archive was generated by hypermail 2.3.0 : Wed Jun 19 2013 - 17:24:05 CEST