[llvm-commits] [llvm] r160419 - /llvm/trunk/lib/Object/MachOObject.cpp
Galina Kistanova
gkistanova at gmail.com
Thu Jul 19 14:44:04 PDT 2012
Hi Michael,
I'm reverting this change.
But we better fixing it soon. Having thousands of warnings does not
make much sense, since they will start actually working only after we
will scale them down to just few real.
Thanks
Galina
On Wed, Jul 18, 2012 at 2:08 AM, Michael Spencer <bigcheesegs at gmail.com> wrote:
> 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