On 2015/04/29 03:43:10, Benedikt Meurer wrote:
On 2015/04/27 07:57:51, titzer wrote:
> https://codereview.chromium.org/1105693002/diff/1/src/heap/identity-map.h
> File src/heap/identity-map.h (right):
>
>

https://codereview.chromium.org/1105693002/diff/1/src/heap/identity-map.h#newcode68
> src/heap/identity-map.h:68: return static_cast<int>((raw_address >> 11) ^
> raw_address);
> On 2015/04/27 06:26:47, Sven Panne wrote:
> > On 2015/04/27 04:04:17, Benedikt Meurer wrote:
> > > Down casting to int looks wrong here. How about using uintptr_t here? Or
> even
> > > better use size_t?
> >
> > Veto from the *San sheriff, too: This line is causing
implementation-defined
> > behavior...
>
> This is the computation of a hashcode from an address and is inherently
> implementation-dependent. This is not _undefined_ behavior.

I think you're talking about different implementation-defined behaviors:
There's
(a) the cast from a pointer to an integral type, which is _desired_
implementation-defined behavior, and (b) the down cast to int, which is
_undesired_ implementation-defined behavior. And I think Sven was only talking
about (b).

If you cast the pointer to unintptr_t then the subsequent downcast to unsigned
(not int) will be well defined, not implementation defined.

It won't, in practice, make any difference to anything, because none of the
compilers we care about define this 'wrong', and in any case the code works
whatever result we calculate here.

V8 is full of undefined behaviour. Tagged pointers, a JIT, Smi 'pointers' etc.
Getting rid of this tiny piece of implementation defined behaviour in a hash
code calculator seems like a waste of time to me.


https://codereview.chromium.org/1105693002/

--
--
v8-dev mailing list
v8-dev@googlegroups.com
http://groups.google.com/group/v8-dev
--- You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to v8-dev+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to