STL bitset failure in GNU compiler (PowerPC) - VxWorks

This is a discussion on STL bitset failure in GNU compiler (PowerPC) - VxWorks ; We are experiencing a problem using the STL bitset container under VxWorks. The application is compiled using the GNU compiler (v2.96 - Tornado 2.2, VxWorks 5.5). The target is a PowerPC 7447 PMC card (PPC604). After many, many hours of ...

+ Reply to Thread
Results 1 to 2 of 2

Thread: STL bitset failure in GNU compiler (PowerPC)

  1. STL bitset failure in GNU compiler (PowerPC)

    We are experiencing a problem using the STL bitset container under
    VxWorks. The application is compiled using the GNU compiler (v2.96 -
    Tornado 2.2, VxWorks 5.5). The target is a PowerPC 7447 PMC card
    (PPC604).

    After many, many hours of debugging and much isolation of code we have
    traced the source down to "bitset.none()" method returning true even
    when the bitset contained bits that have been set (proven by dumping
    the bitset to an output stream). It appears that "bitset.none()" is
    always returning true if there are no bits set in the first 32 bits of
    the bit-set regardless of what is set in the remaining bits of the
    bit-set, we are using bit-sets of 512 bits.

    The following rough and ready code snippet is a contrived example
    demonstrating the issue we are experiencing, which does fail under
    vxworks (target shell log provided). Compiled on a Personal Computer
    (windows and mac) with various versions of GCC this code (and our
    application) works without problems.

    #include
    #include

    #define OBSERVATION_BITSET_N 512

    void test_bitset_1(void)
    {
    std::bitset bs;

    // Set a bit 32 (the 33'rd bit)
    bs.set(32);

    // display the bitset
    std::cout << "bs: " << bs << std::endl;

    if (bs.none())
    {
    std::cout << "bs.none() returned true" << std::endl;
    }
    else
    {
    for (unsigned int k = 0; k < OBSERVATION_BITSET_N; k++)
    {
    if (bs.test(k))
    {
    std::cout << "bs.test() found bit asserted at: "
    << k << std::endl;
    }
    }
    }
    }

    Produces the following output:

    ->
    -> ld < c:\share\BitsetTest.out
    value = 15678224 = 0xef3b10
    -> test_bitset_1
    bs:
    00000000000000000000000000000000000000000000000000 00000000000000000000000000000000000000000000000000 00000000000000000000000000000000000000000000000000 00000000000000000000000000000000000000000000000000 00000000000000000000000000000000000000000000000000 00000000000000000000000000000000000000000000000000 00000000000000000000000000000000000000000000000000 00000000000000000000000000000000000000000000000000 00000000000000000000000000000000000000000000000000 00000000000000000000000000000100000000000000000000 000000000000
    bs.none()

    returned true

    Repeating the test with any bit from Bit 0-31 set, the "bs.none()" call
    returns false as it should.

    Any suggestions and/or experience with this matter is greatly appreciated.

    Thanks
    Scott.


  2. Re: STL bitset failure in GNU compiler (PowerPC)

    Just a follow-up for anyone interested, this problem has been
    reproduced by WindRiver support and the investigation is on-going.

    On 2008-04-11 21:42:53 +0930, Scott White said:

    > We are experiencing a problem using the STL bitset container under
    > VxWorks. The application is compiled using the GNU compiler (v2.96 -
    > Tornado 2.2, VxWorks 5.5). The target is a PowerPC 7447 PMC card
    > (PPC604).
    >
    > After many, many hours of debugging and much isolation of code we have
    > traced the source down to "bitset.none()" method returning true even
    > when the bitset contained bits that have been set (proven by dumping
    > the bitset to an output stream). It appears that "bitset.none()" is
    > always returning true if there are no bits set in the first 32 bits of
    > the bit-set regardless of what is set in the remaining bits of the
    > bit-set, we are using bit-sets of 512 bits.
    >
    > The following rough and ready code snippet is a contrived example
    > demonstrating the issue we are experiencing, which does fail under
    > vxworks (target shell log provided). Compiled on a Personal Computer
    > (windows and mac) with various versions of GCC this code (and our
    > application) works without problems.
    >
    > #include
    > #include
    >
    > #define OBSERVATION_BITSET_N 512
    >
    > void test_bitset_1(void)
    > {
    > std::bitset bs;
    >
    > // Set a bit 32 (the 33'rd bit)
    > bs.set(32);
    >
    > // display the bitset
    > std::cout << "bs: " << bs << std::endl;
    >
    > if (bs.none())
    > {
    > std::cout << "bs.none() returned true" << std::endl;
    > }
    > else
    > {
    > for (unsigned int k = 0; k < OBSERVATION_BITSET_N; k++)
    > {
    > if (bs.test(k))
    > {
    > std::cout << "bs.test() found bit asserted at: "
    > << k << std::endl;
    > }
    > }
    > }
    > }
    >
    > Produces the following output:
    >
    > ->
    > -> ld < c:\share\BitsetTest.out
    > value = 15678224 = 0xef3b10
    > -> test_bitset_1
    > bs:
    > 00000000000000000000000000000000000000000000000000 00000000000000000000000000000000000000000000000000 00000000000000000000000000000000000000000000000000 00000000000000000000000000000000000000000000000000 00000000000000000000000000000000000000000000000000 00000000000000000000000000000000000000000000000000 00000000000000000000000000000000000000000000000000 00000000000000000000000000000000000000000000000000 00000000000000000000000000000000000000000000000000 00000000000000000000000000000100000000000000000000 000000000000

    bs.none()
    returned
    >
    > true
    >
    > Repeating the test with any bit from Bit 0-31 set, the "bs.none()" call
    > returns false as it should.
    >
    > Any suggestions and/or experience with this matter is greatly appreciated.
    >
    > Thanks
    > Scott.




+ Reply to Thread