[cfe-commits] [PATCH 01/15] Fix Cast Code
dag at cray.com
dag at cray.com
Thu Jan 10 14:08:26 PST 2013
Dmitri Gribenko <gribozavr at gmail.com> writes:
> On Thu, Jan 10, 2013 at 9:12 PM, David Greene <dag at cray.com> wrote:
>> Fix casting to avoid cast-away-const errors.
>
> ProtocolQualifiers = new Decl*[NP];
> ProtocolLocs = new SourceLocation[NP];
> - memcpy((void*)ProtocolQualifiers, Protos, sizeof(Decl*)*NP);
> + memcpy(const_cast<Decl **>(ProtocolQualifiers), Protos, sizeof(Decl*)*NP);
>
> A better fix is to avoid a cast -- introduce a local variable of the
> correct type and initialize it with new Decl*[NP] here, memcpy, and
> assign to the data member after that.
Ok, I'll work on that.
Do the rest of the patches look ok?
-David
More information about the cfe-commits
mailing list