Warning C6385 Reading invalid data from 'CRdr': the readable size is '(unsigned int)*108+4' bytes, but '216' bytes may be read.
struct CReaders
{
int m_IntAddr{}; CStringA m_HexAddr = _T(""); CStringA m_Loc = _T(""); CStringA m_Desc = _T(""); int m_BUS{}; BOOL m_ELEVATOR{};
CStringA m_CmdLv = _T(""); int m_CmdLvInt[CMD_MAX]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}; BOOL m_VOID{};
int m_Type{}; volatile BOOL m_GOOD_CHK{}; BOOL m_DISPLAY{}; BOOL m_DISPLAY_OFFLine{};};
m_ReaderSet->MoveFirst();
do
{
m_ReaderCount++; m_ReaderSet->MoveNext();
}while(!m_ReaderSet->IsEOF());
if(m_ReaderCount > READERS_MAX)
m_ReaderCount = READERS_MAX;
if(CRdr)
delete [] CRdr;
CRdr = 0;
CRdr = new CReaders[m_ReaderCount+10];
for(c=0;c<=(int)m_ReaderCount+1;c++)
{
CRdr[c].m_BUS = 0;
CRdr[c].m_ELEVATOR = FALSE;
CRdr[c].m_GOOD_CHK = TRUE;
CRdr[c].m_IntAddr = 0;
CRdr[c].m_Type = 0;
CRdr[c].m_VOID = FALSE;
CRdr[c].m_DISPLAY = FALSE;
CRdr[c].m_DISPLAY_OFFLine= FALSE;
CRdr[c].m_Loc = _T(""); CRdr[c].m_HexAddr = _T("");
CRdr[c].m_CmdLv = _T("");
CRdr[c].m_Desc = _T("");
}
CStringA packs to 8 bits. Column for m_Loc is nvarchar(50), null in the DB. In the
program, its pulled out via CStringA:
RFX_Text(pFX, _T("[Loc]"), m_Loc); //m_Loc is a CStringA
My Question is: How do I remove this warning?
The compiler is VS2019 "all warnings" and I discovered this by using the Analize tool on VS2019.
Compiler set to "Use Multi-Byte Character Set"
The compiler doesn't know the DB so the 50 nvarchar is unknown to the compiler.
I can't do anything with the CStringA in the structure except
initialize it with a NULL or nothing.
Wanted to set its limit but can't be don't during initializing. I can "Release buffer, Set limit" later but that doesn't get rid of the warning.
Compiler is using the standard 8 bit packing for structures.
I would like to give more code but this is a part of 300,000 line code I made. The program works fine and has been for years but this is the
last annoyance I would like to tackle but don't know how, any clues?
This is one example:
I have 10 other structures with CStrings as members that have the same warnings.
One other struct is using CTime m_EndSched{}; as a member and getting the same warning.
Warning C6385 Reading invalid data from 'SchdLvl': the readable size is '(unsigned int)*100+4' bytes, but '200' bytes may be read.
DB=EndDate(datetime,null)
The very last resort to change all CStrings to char but that means using sprintf/scopy/strcat/sprintf_s (which will be banned soon)or the format command on a CString in reverse.
What I have tried:
I have tried to init the CString in the struct but its illegal. I tried packing to 2,4,8,16 bits using #pragma pack(n) or in the compiler itself. I tried to "Release set limit" to the CString later in the code but the compiler still has the warning.