stdcxx-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Martin Sebor (JIRA)" <j...@apache.org>
Subject [jira] Commented: (STDCXX-904) [HP aCC 6.16] bogus cadvise warning #20206 in optimized code
Date Tue, 06 May 2008 04:33:55 GMT

    [ https://issues.apache.org/jira/browse/STDCXX-904?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12594463#action_12594463
] 

Martin Sebor commented on STDCXX-904:
-------------------------------------

Dennis' response:

------- Original Message --------
Subject: Re:  bogus warning 20206 on a memcpy-like loop with +O2
Date: Mon, 5 May 2008 19:18:40 -0700 (PDT)
From: Dennis Handly <dhandly AT cup DOT hp DOT com>
To: acxx AT cup DOT hp DOT com, sebor AT roguewave DOT com

>From: Martin Sebor <sebor AT roguewave DOT com>
>Here's a new test case for an apparent aCC bug reduced from our test suite.

It seems directly related to the "%" operator.  Using "i" or a constant
makes it go away.
You can also duplicate this if the class B is moved to file scope.

The only way I found to make the warning go away is to use signed for this
for-loop:
     {{for (int i = 3; i != n - 1; --i)}}

Not sure why since both should wrap around.  If "n" and "i" are both ints
we get a different range message.
{noformat}
     struct B {
         char x[4];
         void bar(unsigned n) {
             for (unsigned i = 3; i != n - 1; --i)
                 x[i] = x[i - n];
         }
     } x;
     for (unsigned i = 0; i != 1; ++i) {
         x.bar(i % 4);
     }
{noformat}

> [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