Boost logo

Boost :

From: George M. Garner Jr. (gmgarner_at_[hidden])
Date: 2005-12-13 01:10:51


John,

I have been trying to reproduce your warning with the following pseudo-code:

unsigned long foo()
{
static const unsigned long masks[20] =
{
0,
0x0104u, // C1_ALPHA | C1_DIGIT
0x0100u, // C1_ALPHA
0x0040u, // C1_BLANK
0x0020u, // C1_CNTRL
0x0004u, // C1_DIGIT
0x0004u, // C1_DIGIT
(~(0x0020u|0x0008u|0x0040) & 0x01ffu) | 0x0400u, // not C1_CNTRL or C1_SPACE
or C1_BLANK
0x0002u, // C1_LOWER
0x0002u, // C1_LOWER
(~0x0020u & 0x01ffu) | 0x0400, // not C1_CNTRL
0x0010u, // C1_PUNCT
0x0008u, // C1_SPACE
0x0008u, // C1_SPACE
0x0001u, // C1_UPPER
0x0800,
0x0001u, // C1_UPPER
0x0104u | (1u << 25),
0x0104u | (1u << 25),
0x0080u, // C1_XDIGIT
};
//int id1 = -1; //no error
//int id1 = 18; //no error
int id1 = 19; //error C6385: Invalid data: accessing 'unsigned long const *
const `unsigned long __cdecl foo(void)'::`2'::masks', the readable size is
'80' bytes, but '84' bytes might be read: Lines: 80, 106, 107, 108, 109
std::size_t id = (1 + id1);
_ASSERTE(id < (sizeof(masks) / sizeof(masks[0])));
return masks[id];
}

The only time that I get warning 6385 is when id is equal to or exceeds the
size of the array. It is a little strange in that the warning only occurs
when the line beginning with _ASSERTE is added. There should be an error
even without the debug assertion. Nevertheless this suggests that there may
be a case where
re_detail::get_default_class_id(() returns a value in excess of 18 leading
to the warning. The following pseudo-code compiles without warning or error
and has the slight advantage if protecting release as well as debug builds:

std::size_t id = (1 + re_detail::get_default_class_id(p1, p2));
if(id < sizeof(masks) / sizeof(masks[0]))
    return masks[id];
return masks[0];

> Understood, but what other warnings were you seeing? <

Here is the build log which already incorporates the above code fragment:
http://users.erols.com/gmgarner/boost/BuildLog_regex.txt.

Also, the build incorporates the following warningstate.h file:
http://users.erols.com/gmgarner/boost/WarningState.h; and I added the
following lines to visualc.hpp:

#if (_MSC_VER >= 1400)
#include "warningstate.h"
#endif //(_MSC_VER >= 1400)

Regards,
George.


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk