[HP aCC 6.16] bogus cadvise warning #20206 on safe code
-------------------------------------------------------
Key: STDCXX-829
URL: https://issues.apache.org/jira/browse/STDCXX-829
Project: C++ Standard Library
Issue Type: Bug
Components: External
Environment: $ uname -sr && aCC -V
HP-UX B.11.31
aCC: HP C/aC++ B3910B A.06.16 [Nov 26 2007]
Reporter: Travis Vitek
Copying data from one buffer to a smaller one results in the warning, even if
you check for overflow before the copy.
{noformat}
$ 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].)
{noformat}
A workaround is to create a plain pointer to the source buffer and then do the
copy.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.