Uploaded image for project: 'C++ Standard Library'
  1. C++ Standard Library
  2. STDCXX-904

[HP aCC 6.16] bogus cadvise warning #20206 in optimized code

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Open
    • Priority: Major
    • Resolution: Unresolved
    • Affects Version/s: 4.2.1
    • Fix Version/s: None
    • Component/s: External
    • Labels:
      None
    • Environment:

      $ uname -sr && aCC -V
      HP-UX B.11.31
      aCC: HP C/aC++ B3910B A.06.16 [Nov 26 2007]

    • Severity:
      Compiler Warning

      Description

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

      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;
      }
      

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

      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].)
      

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

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                Unassigned
                Reporter:
                vitek Travis Vitek
              • Votes:
                0 Vote for this issue
                Watchers:
                0 Start watching this issue

                Dates

                • Created:
                  Updated: