lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Stuart P. Bentley wrote:
It starts returning nil around 2^63, but for some range between 2^34 and 2^63-2^9 the Lua for Windows interpreter just crashes (at least on my Windows XP laptop from 2004).

--------------------------------------------------
From: "Stuart P.Bentley"
Sent: Wednesday, September 23, 2009 P7:42
Newsgroups: gmane.comp.lang.lua.general
To: <lua@bazar2.conectiva.com.br>
Subject: os.date("%x",2^35) crashing on Windows

This might make sense as a 32-bit int overflow, but 2^34 works...

Sounds like the Thomas Edison way, 99% perspiration... :-)

loslib.c[126]:

  time_t t = luaL_opt(L, (time_t)luaL_checknumber, 2, time(NULL));

On MinGW, it's a long, I think. That would be 32 bits.

IIRC, the MSVCRT strftime is seriously nutty. For the format string, stick to the primitive ones, you should avoid the fancy ones like %G. You didn't specify exactly how the thingy was compiled, but normally, do assume that Win32 does not follow POSIX. I always stick to a safe or conservative subset of POSIX.

--
Cheers,
Kein-Hong Man (esq.)
Kuala Lumpur, Malaysia