Still buggy regular expressions – Visual Studio .NET 2005 Service Pack 1

It is somewhat unexpected but it’s MS Visual Studio .NET 2005 Service Pack 1 already and exactly the same bug in atlrx.h is still here, though the place has been reworked with MS Visual Studio .NET 2005.

So, atlrx.h near line 745, “case RE_NOTRANGE:” branch:

size_t u = static_cast(static_cast<_TUCHAR>(* ((RECHAR *) sz)));
ATLASSERT((u >> 3) < (256 / 8));

Add ATLASSERT line shown above and it will assert in Unicode Debug build…


Complete workaround for the problem:

// FIX: Alax.Info’s fix for the “Value is erroneously treated as signed” bug
#if TRUE
ATLASSERT(sizeof *sz == 1);
size_t u = (size_t) (UCHAR) *sz;
#else
size_t u = static_cast(static_cast<_TUCHAR>(* ((RECHAR *) sz)));
#endif
ATLASSERT((u >> 3) < (256 / 8 ));

Original source code line is shown as italic.

Leave a Reply