Incorrect usage of || (logical or) instead of | (bitwise or)

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Incorrect usage of || (logical or) instead of | (bitwise or)

Nicolas Cellier
 
Hi,
Among the compiler warnings, I noticed an incorrect usage of || in generated C:
in okayOoop:

    unusedBits = (1 << 22) || (1LL << (22 + 32));
    if (((long64At(oop)) & unusedBits) != 0) {
        error("some unused header bits are set; should be zero");
        return 0;
    }
    unusedBitsInYoungObjects = ((1 << 0x1F) || (1 << 30)) || (1 << 29);
    if (((longAt(oop)) & unusedBitsInYoungObjects) != 0) {
        error("some header bits unused in young objects are set; should be zero");
        return 0;

C || will generate 1 in this case (true) but not the intended bit mask.
This is because Smalltalk slang is written with | instead of bitOr:

Find correction in attachment.

Nicolas

SpurMemoryManager-newSpaceRefCountMask.st (866 bytes) Download Attachment
SpurMemoryManager-checkOkayOop.st (3K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Incorrect usage of || (logical or) instead of | (bitwise or)

Nicolas Cellier
 
Jamais deux sans trois

2015-03-18 23:33 GMT+01:00 Nicolas Cellier <[hidden email]>:
Hi,
Among the compiler warnings, I noticed an incorrect usage of || in generated C:
in okayOoop:

    unusedBits = (1 << 22) || (1LL << (22 + 32));
    if (((long64At(oop)) & unusedBits) != 0) {
        error("some unused header bits are set; should be zero");
        return 0;
    }
    unusedBitsInYoungObjects = ((1 << 0x1F) || (1 << 30)) || (1 << 29);
    if (((longAt(oop)) & unusedBitsInYoungObjects) != 0) {
        error("some header bits unused in young objects are set; should be zero");
        return 0;

C || will generate 1 in this case (true) but not the intended bit mask.
This is because Smalltalk slang is written with | instead of bitOr:

Find correction in attachment.

Nicolas


SpurMemoryManager-okayOop.st (2K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Incorrect usage of || (logical or) instead of | (bitwise or)

Eliot Miranda-2
 
Thanks Nicolas,

    I did find a couple of others.  My bad :(

On Wed, Mar 18, 2015 at 3:37 PM, Nicolas Cellier <[hidden email]> wrote:
 
Jamais deux sans trois

2015-03-18 23:33 GMT+01:00 Nicolas Cellier <[hidden email]>:
Hi,
Among the compiler warnings, I noticed an incorrect usage of || in generated C:
in okayOoop:

    unusedBits = (1 << 22) || (1LL << (22 + 32));
    if (((long64At(oop)) & unusedBits) != 0) {
        error("some unused header bits are set; should be zero");
        return 0;
    }
    unusedBitsInYoungObjects = ((1 << 0x1F) || (1 << 30)) || (1 << 29);
    if (((longAt(oop)) & unusedBitsInYoungObjects) != 0) {
        error("some header bits unused in young objects are set; should be zero");
        return 0;

C || will generate 1 in this case (true) but not the intended bit mask.
This is because Smalltalk slang is written with | instead of bitOr:

Find correction in attachment.

Nicolas





--
best,
Eliot