[llvm-commits] [llvm] r160419 - /llvm/trunk/lib/Object/MachOObject.cpp
Michael Spencer
bigcheesegs at gmail.com
Wed Jul 18 02:08:15 PDT 2012
On Tue, Jul 17, 2012 at 9:06 PM, Galina Kistanova <gkistanova at gmail.com> wrote:
> Author: gkistanova
> Date: Tue Jul 17 23:06:49 2012
> New Revision: 160419
>
> URL: http://llvm.org/viewvc/llvm-project?rev=160419&view=rev
> Log:
> Fixed few warnings.
>
> Modified:
> llvm/trunk/lib/Object/MachOObject.cpp
>
> Modified: llvm/trunk/lib/Object/MachOObject.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Object/MachOObject.cpp?rev=160419&r1=160418&r2=160419&view=diff
> ==============================================================================
> --- llvm/trunk/lib/Object/MachOObject.cpp (original)
> +++ llvm/trunk/lib/Object/MachOObject.cpp Tue Jul 17 23:06:49 2012
> @@ -44,7 +44,8 @@
> }
>
> // Check whether we can return a direct pointer.
> - struct_type *Ptr = (struct_type *) (Buffer.data() + Base);
> + struct_type *Ptr =
> + const_cast<struct_type *>((const struct_type *)(Buffer.data() + Base));
This is incorrect. Although so was the code before. I would rather
keep the warning so it can be fixed properly rather than incorrectly
silenced.
The problem here is that the Buffer this gets may indeed originate
from const data. And more likely originates from data that should not
be modified (read only mmap pages).
I believe the proper solution would be to require T to already be
const via template magic.
> if (!MOO.isSwappedEndian()) {
> Res = Ptr;
> return;
http://llvm-reviews.chandlerc.com/rL160419
- Michael Spencer
More information about the llvm-commits
mailing list