Board index » cppbuilder » CodeGuard + global arrays -> false access overrun report

CodeGuard + global arrays -> false access overrun report


2004-04-14 08:30:20 PM
cppbuilder17
If I have global array of char with size less than 4, CG will report
"access overrun report":
(I use BCB v 6.0)
File unit1.h:
//--------------------------------------------------------------------------
-
#ifndef Unit1H
#define Unit1H
//--------------------------------------------------------------------------
-
#include <Forms.hpp>
//--------------------------------------------------------------------------
-
const char my_array[3] = {0x01, 0x02, 0x03};
class TForm1 : public TForm
{
__published: // IDE-managed Components
private: // User declarations
public: // User declarations
__fastcall TForm1(TComponent* Owner);
};
//--------------------------------------------------------------------------
-
extern PACKAGE TForm1 *Form1;
//--------------------------------------------------------------------------
-
#endif
File unit1.cpp:
//--------------------------------------------------------------------------
-
#include <vcl.h>
#pragma hdrstop
#include "Unit1.h"
//--------------------------------------------------------------------------
-
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
//--------------------------------------------------------------------------
-
__fastcall TForm1::TForm1(TComponent* Owner)
:TForm(Owner)
{
char second_array[128];
memcpy(second_array, my_array, 3);
}
//--------------------------------------------------------------------------
-
 
 

Re:CodeGuard + global arrays -> false access overrun report

It /might/ be that memcpy() works in 4 byte chunks in which case CG is
correct in the warning.
OTOH it could be a bug in CG in which case..shame. Bugs in CG were never
very likely to get fixed and now that BCB6 has been superceded the chances
must have hit zero. We just have to make do with what Borland have left us.
--
Andrue Cope
[Bicester UK]