lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


This seems like the most annoying case of excessive optimization possible.
Why on Earth would you want this?  Two static const variables with the same
value could still represent different purposes - the compiler and linker
have no business optimizing out your purpose.

Thanks for the heads-up, though.  Talk about a gotcha waiting to happen....

Richard

> PIL 27.3 describes this technique as "bulletproof" to get a
> unique address. Alas, it's not.
>
> The problem is that the compiler/linker may decide to join
> constants with identical _values_. Unfortunately this makes the
> _addresses_ the same, too. This in turn means the lightuserdata
> keys are the same and happily overwrite each other in the
> registry. :-(
>
> Note that the linker may even decide to join constants from
> different source files, linked to the same executable or shared
> library.
>
> [This is not a theory: LuaJIT 1.1.1 was broken on Mac OS X due to
> this issue (GCC 4.0 + Mach linker).]