On 22/07/2013 12:17 PM, Charles Mills wrote:
# 0 and NOINLINE TEST or 2 and INLINE NOTEST
#  OPT(0) NOINLINE   TEST   GONUMBER
    OPT(2)   INLINE NOTEST NOGONUMBER COMPRESS

Are you concerned about the size of your load modules? I can understand that in C++ code that uses STL templates but I would trade off bigger load modules
for the better diagnostics that OFFSET GONUMBER give me.

#  Turn on the LIST option - "pseudo-assembler" listing
#  LIST
#  Experiment for XXXXXXXX - does not seem to hurt anything
    DLL(CBA)

Charles

-----Original Message-----
From: IBM Mainframe Discussion List [mailto:IBM-MAIN@LISTSERV.UA.EDU] On
Behalf Of Charles Mills
Sent: Sunday, July 21, 2013 8:57 PM
To: IBM-MAIN@LISTSERV.UA.EDU
Subject: Re: Looking for help with an obscure C integer problem

Here is exact cut and paste with zero editing, complete with a typo in the
second comment. The code is unit tested on MS Visual Studio -- hence the two
#ifdef's.

        // Find First Set
        static inline int Ffs64(unsigned long long valueToTest)
        {
                // returns index of first set bit. Uses UNIX convention
where bit 1 is LSB of word for compatibilit with z/OS ffs()

                static const unsigned long long lswMask =
0x00000000ffffffff;

                // note Windows provides a _BitScanForward64() but I did it
this way to make it more z/OS-like for test purposes
                // if we ever needed Windows efficiency, or if IBM provides
an ffs64(), then this should be re-written to take advantage

                if ( valueToTest == 0 ) return 0;

                unsigned int testWord;
                testWord = valueToTest & lswMask;
                if ( testWord != 0 )
                {
                        // _BitScanForward returns base 0
#ifdef WIN32
                        unsigned long index;
                        _BitScanForward(&index, testWord);
                        return index+1;
#else
                        return ffs(testWord);
#endif
                }
                else
                {
                        testWord = valueToTest >> 32;
#ifdef WIN32
                        unsigned long index;
                        _BitScanForward(&index, testWord);
                        return index+33;
#else
                        return ffs(testWord) + 32;
#endif

                }
        }

I have strong -- but not utterly conclusive; you know what debugging a
complex program is like -- that for the value I had in the OP --
0x0034000000000000? -- the method returns 32, implying that the final ffs()
was called with testWord = 0.

Charles

-----Original Message-----
From: IBM Mainframe Discussion List [mailto:IBM-MAIN@LISTSERV.UA.EDU] On
Behalf Of David Crayford
Sent: Sunday, July 21, 2013 8:31 PM
To: IBM-MAIN@LISTSERV.UA.EDU
Subject: Re: Looking for help with an obscure C integer problem

I'm struggling to see what is wrong with testWord = valueToTest >> 32.
There are no side effects and the sequence point is at the end of the full
expression. Can anybody enlighten me?
Charles, is the code snippet you supplied the exact test cast that is
resulting in undefined behaviour? I cannot recreate the problem and I've
tried it on five different C++ compilers, including z/OS v1.13.

----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN

----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN

Reply via email to