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

[HP aCC 6.16] bogus cadvise warning #20206 on safe code

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Major
    • Resolution: Unresolved
    • None
    • None
    • External
    • None
    • $ uname -sr && aCC -V
      HP-UX B.11.31
      aCC: HP C/aC++ B3910B A.06.16 [Nov 26 2007]

    • Compiler Warning

    Description

      Copying data from one buffer to a smaller one results in the warning, even if you check for overflow before the copy.

      $ cat t.cpp && aCC +w -c t.cpp
      #include <string.h>
      
      int main (int argc, char* argv[])
      {
          char a [32] = { 'a', 'b', 'c', '\0' };
          char b [16];
      
          const size_t n = strlen (a) + 1;
          if (sizeof (b) < n)
              return 1;
      
          strcpy (b, a);
      
          return 0;    
      }
      "t.cpp", line 12, procedure main: warning #20206-D: Out of bound access (In
                expression "strcpy((char*)b, (char*)a)", variable "b" [t.cpp:6]
                (type: char [16]) has byte range [0 .. 15], writing byte range [0 ..
                31].)
      

      A workaround is to create a plain pointer to the source buffer and then do the copy.

      Attachments

        Issue Links

          Activity

            People

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

              Dates

                Created:
                Updated: