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: Roland King <email@hidden>
- Date: Tue, 08 Apr 2014 22:39:53 +0800
On 8 Apr, 2014, at 10:25 pm, Jens Alfke < email@hidden> wrote: 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
So LLDB is wrong then when it refuses to evaluate such an _expression_? Perhaps there's a disconnect between the build flags (I see the default is gnu99, I don't think I changed that) and what LLDB accepts.
Agree that void* treated as 1 byte is useful and obvious, but it probably isn't C99. So should LLDB respect build flags? |
_______________________________________________
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