stdcxx-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Travis Vitek (JIRA)" <j...@apache.org>
Subject [jira] Created: (STDCXX-904) [HP aCC 6.16] bogus cadvise warning #20206 in optimized code
Date Wed, 30 Apr 2008 23:44:55 GMT
[HP aCC 6.16] bogus cadvise warning #20206 in optimized code
------------------------------------------------------------

                 Key: STDCXX-904
                 URL: https://issues.apache.org/jira/browse/STDCXX-904
             Project: C++ Standard Library
          Issue Type: Bug
          Components: External
    Affects Versions: 4.2.1
         Environment: $ uname -sr && aCC -V 
HP-UX B.11.31
aCC: HP C/aC++ B3910B A.06.16 [Nov 26 2007] 
            Reporter: Travis Vitek



This is a simplified version of 23.bitset.cpp that shows a bogus out of bound access cadvise
warning. 

{noformat}
void __rw_bitset (unsigned*, unsigned, const char*, unsigned, unsigned, unsigned);

template <unsigned _Size>
class bitset
{
    unsigned bits_ [1];

public:

    bitset (const char *__str, unsigned __pos, unsigned __n) {
        __rw_bitset (bits_, _Size, __str, 0, __pos, __n);
    }
};

template <unsigned _Size>
struct test_set
{
    char bits_ [_Size + 1]; // includes a null terminator

    test_set () {
        for (unsigned i = 0; i != _Size; ++i)
            bits_ [i] = '0';
        bits_ [_Size] = '\0';   
    }

    test_set& operator>>= (unsigned n) {
        for (unsigned i = _Size - 1; i != n - 1; --i)
            bits_ [i] = bits_ [i - n];
        for (unsigned j = n; j != 0; )
            bits_ [--j] = '0';
        return *this;
    }
};

template <unsigned _Size>
void run_test ()
{
    test_set<_Size> ts0;

    const unsigned M = _Size + 1;
    for (unsigned i = 0; i != 1; ++i) {
        const unsigned n = i % M;
         
        const test_set<_Size> ts1 = (ts0 >>= n);
        (void)&ts1;

        const bitset<_Size> bs0 (ts0.bits_, 0, _Size);
    }
}

int main (int argc, char *argv[])
{
    run_test<31>();
    return 0;
}
{noformat}

The result of compiling this code with -O2 is...

{noformat}
aCC -c -mt \
  -I/amd/devco/vitek/stdcxx/4.2.x/include \
  -I/amd/devco/vitek/stdcxx/4.2.x/build/include \
  -I/amd/devco/vitek/stdcxx/4.2.x/tests/include \
  -AA  +O2  +DD64 +w \
  +W392,655,684,818,819,849 \
  +W2193,2236,2261,2340,2401,2487 \
  +W4227,4229,4231,4235,4237,4249 \
  +W4255,4272,4284,4285,4286,4296,4297 \
  +W3348 u.cpp
"u.cpp", line 29, procedure main: warning #20206-D: Out of bound access \
  (In expression "memmove(&(&ts0)->bits_[30]+1 - (31 - n),&(&ts0)->bits_[(30
- n)]+1 - (31 - n),31 - n)", &(&ts0)->bits_[30]+1 - (31 - n)  \
(type: char [32]) (defined by (&ts0)->bits_) has byte range [0 .. 31], writing byte
range [0 .. 60].)
{noformat}

The code compiles without warning if the optimization level is reduced to -O1.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


Mime
View raw message