[haiku-bugs] Re: [Haiku] #10396: [PATCHSET] Make Haiku userland compile and work with Clang

  • From: "js" <trac@xxxxxxxxxxxx>
  • Date: Sun, 12 Jan 2014 12:40:25 -0000

#10396: [PATCHSET] Make Haiku userland compile and work with Clang
---------------------------+----------------------------
   Reporter:  js           |      Owner:  bonefish
       Type:  enhancement  |     Status:  closed
   Priority:  normal       |  Milestone:  R1/beta1
  Component:  - General    |    Version:  R1/Development
 Resolution:  fixed        |   Keywords:  clang
 Blocked By:               |   Blocking:
Has a Patch:  1            |   Platform:  All
---------------------------+----------------------------

Comment (by js):

 Ok, I thought you meant another example, because the one you gave was
 pretty obvious to me. The [] operator comes before the & operator
 (operator precedence). There is no explicit [] operator, so it falls back
 to the C behaviour, where [] is just *(pointer + offset). As it needs a
 pointer, it uses the Type* operator(). Then it can evaluate
 someInts[arrayIndex] and takes the pointer of that and cast it. It all
 boils down to operator precedence. Would it be more obvious to you if the
 code were "(size_t*)(&(someInts[arrayIndex]))"? Because that's basically
 how the compiler treats it due to operator precedence.

--
Ticket URL: <http://dev.haiku-os.org/ticket/10396#comment:25>
Haiku <http://dev.haiku-os.org>
Haiku - the operating system.

Other related posts: