[U-Boot] [PATCH 2/3] md5: Fix gcc-4.7 build problem in md5

Han Shen(沈涵) shenhan at google.com
Mon Nov 5 22:15:40 CET 2012


On Mon, Nov 5, 2012 at 12:50 PM, Wolfgang Denk <wd at denx.de> wrote:

> Dear Pavel,
>
> In message <20121105200340.GA15821 at xo-6d-61-c0.localdomain> you wrote:
> >
> > > > >         /* Append length in bits and transform */
> > > > > -       ctx->in32[14] = ctx->bits[0];
> > > > > -       ctx->in32[15] = ctx->bits[1];
> > > > > +       memcpy(ctx->in + 14 * sizeof(__u32), ctx->bits, 2 *
> sizeof(__u32));
> > > >
> > > > This makes the code actually unreadable.  Please add at least a
> > > > comment what this is doing.
> > >
> > > Actually I think this shoul dbe split into two memcpy commands, using
> > > the addresses of the respective array elements directly, without such
> > > manual pointer arithmetics.
> >
> > I guess bigger question is: why does gcc miscompile that, and is it
> > guaranteed that it will not miscompile the memcpy?
>
> I did not see Simon mentioning anythin about incorrect compilation.
> My understanding was that it's just the usual "dereferencing
> type-punned pointer" warnings issue.
>

Yup, it's a compilation warning. issue.  (but warnings being treated as
errors.)


>
>
> Simon, what was the actual problem this was supposed to fix?
>
> Best regards,
>
> Wolfgang Denk
>
> --
> DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
> HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
> Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
> Let's say the docs present a simplified view of reality...    :-)
>                       - Larry Wall in  <6940 at jpl-devvax.JPL.NASA.GOV>
>



-- 
 Han Shen |  Software Engineer |  shenhan at google.com |  +1-650-440-3330


More information about the U-Boot mailing list