This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author larry
Recipients amaury.forgeotdarc, asvetlov, eric.smith, larry, loewis, mark.dickinson, meador.inge, pitrou, rhettinger, sdaoden, serhiy.storchaka, stutzbach, vstinner, xuanji
Date 2012-09-22.14:11:22
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
I must be missing something--because I thought Python *already* depended on this apparently-undefined behavior.  The small-block object allocator in Objects/obmalloc.c determines whether a pointer belongs to a particular arena using exactly this trick.  I quote from the gigantic comment at the top of that file:

    Let B be the arena base address associated with the pool,
    B = arenas[(POOL)->arenaindex].address.  Then P belongs to
    the arena if and only if

        B <= P < B + ARENA_SIZE

    Subtracting B throughout, this is true iff

        0 <= P-B < ARENA_SIZE

This test is implemented as the following macro:

    #define Py_ADDRESS_IN_RANGE(P, POOL)                    \
        ((arenaindex_temp = (POOL)->arenaindex) < maxarenas && \
     (uptr)(P) - arenas[arenaindex_temp].address < (uptr)ARENA_SIZE && \
     arenas[arenaindex_temp].address != 0)

Why is that permissible but _PyLong_IS_SMALL_INT is not?
Date User Action Args
2012-09-22 14:11:26larrysetrecipients: + larry, loewis, rhettinger, amaury.forgeotdarc, mark.dickinson, pitrou, vstinner, eric.smith, stutzbach, asvetlov, meador.inge, xuanji, sdaoden, serhiy.storchaka
2012-09-22 14:11:25larrysetmessageid: <>
2012-09-22 14:11:25larrylinkissue10044 messages
2012-09-22 14:11:22larrycreate