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: Jens Alfke <email@hidden>
- Date: Tue, 08 Apr 2014 07:25:06 -0700
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.
—Jens |
_______________________________________________
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