Re: I thought void* arithmetic was not allowed
Re: I thought void* arithmetic was not allowed
- Subject: Re: I thought void* arithmetic was not allowed
- From: Wayne J <email@hidden>
- Date: Tue, 08 Apr 2014 07:35:10 -0700
On Apr 8, 2014, at 7:29 AM, Jean-Daniel Dupas <email@hidden> wrote:
>
> Le 8 avr. 2014 à 16:25, Jens Alfke <email@hidden> a écrit :
>
>>
>> On Apr 8, 2014, at 6:05 AM, Keary Suska <email@hidden> wrote:
>>
>>> As long as base_ptr is not a void * the compiler may have sufficient information to perform proper pointer arithmetic. Otherwise, I would expect it to be an error and you may want to file a bug report.
>>
>> Nope. Arithmetic on void* pointers is a longstanding extension to C that began in GCC and is supported by Clang. For the purposes of this arithmetic the pointer’s item size is treated as 1 byte, as though it were a char*.
>>
>> I personally find this very useful. I’m not sure how to turn it off, but there’s probably a compiler flag to do so.
>
> You can enable warning on pointer arithmetic:
>
> -Wpointer-arith
>
>
>
Also, with the flag -pedantic-errors you get the standard C behavior of generating an error.
Wayne
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden