Hi Ben!
>>Is there some provision for changing msvcr80d so that this assert
doesn't happen?
This is a limitation of the C-Standard not the CRT.
To handle date/times < 1900/1970 you must not use the C-Runtime.
YOu should use FindFirstFile/FindNextFile and FILETIME
>>full details and stack can be found at:
https://bugzilla.mozilla.org/show_bug.cgi?id=331404
And what should be the solution in the C-Runtime?
It should most certainly not assert. Assertions should only catch program
errors, not exceptional conditions in the environment.
As a small addition:
The release version of the CRT never asserts.
BUT: In the VC8 CRT MS improved and extended many validation of
arguments and values inside the CRT!
Then it will crash you app (execute an breakpoint-instruction) if it
encounters some "unhandled" situation.
See "_VALIDATE_RETURN" macro.
So the following code will crash your app with the following error message:
Microsoft Visual Studio C Runtime Library has detected a fatal error in
CPP.exe.
You can verify this with the following example:
#include <windows.h>
#include <tchar.h>
#include <io.h>
int _tmain()
{
HANDLE h = CreateFile(_T("\\old.file"), GENERIC_WRITE, 0, NULL,
CREATE_ALWAYS, 0, NULL);
SYSTEMTIME st;
ZeroMemory(&st, sizeof(st));
st.wDay = 1;
st.wMonth = 1;
st.wYear = 1602;
FILETIME ft;
SystemTimeToFileTime(&st, &ft);
SetFileTime(h, &ft, &ft, &ft);
CloseHandle(h);
_finddata32_t ff;
_findfirst32("\\old.file", &ff);
}
You can only prevent this by specifying and "invalid parameter handler":
#include <windows.h>
#include <tchar.h>
#include <io.h>
void myInvalidParameterHandler(const wchar_t* expression,
const wchar_t* function,
const wchar_t* file,
unsigned int line,
uintptr_t pReserved)
{
wprintf(L"Invalid parameter detected in function %s."
L" File: %s Line: %d\n", function, file, line);
wprintf(L"Expression: %s\n", expression);
}
int _tmain()
{
HANDLE h = CreateFile(_T("\\old.file"), GENERIC_WRITE, 0, NULL,
CREATE_ALWAYS, 0, NULL);
SYSTEMTIME st;
ZeroMemory(&st, sizeof(st));
st.wDay = 1;
st.wMonth = 1;
st.wYear = 1602;
FILETIME ft;
SystemTimeToFileTime(&st, &ft);
SetFileTime(h, &ft, &ft, &ft);
CloseHandle(h);
_set_invalid_parameter_handler(myInvalidParameterH andler);
_finddata32_t ff;
_findfirst32("\\old.file", &ff);
}
But this might trigger some followup-errors, because the datetime-field
of the "ff" structure will be "NULL"...
Also there are some error, which can't be catched...
See: "SetUnhandledExceptionFilter" and VC8
http://blog.kalmbachnet.de/?postid=75
Greetings
Jochen