[Lazarus] Weird object variables access - fpc issue?

Mattias Gaertner nc-gaertnma at netcologne.de
Tue Oct 24 13:59:17 CEST 2017

On Tue, 24 Oct 2017 12:41:11 +0100
el es via Lazarus <lazarus at lists.lazarus-ide.org> wrote:

> Now() is literally 
> function Now : TDateTime;
> var ASystemTime : TSYSTEMTIME;
> begin
>    GetSystemTime(ASystemTime);
>    Result := SystemTimeToDateTime(ASystemTime);
> end;
> on my installation (lazarus 1.6.4 #54278, FPC 3.0.2)
> I'd say it's questionable to say it's thread-safe that way; It may be safe to use in
> main thread (where no 2 different contexts can mangle each others ASystemTime);

ASystemTime is a stack variable. That's thread-safe.

In fpc trunk it calls GetLocalTime on Unix, which fetches timezone
every time. No global var. So it should be thread safe.

> because each thread instance would have its own local variables, right?
> so no thread would step on each others' toes;

You have to check called code too.


More information about the Lazarus mailing list