gm2
[Top][All Lists]
Advanced

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

Re: gettimeofday failing


From: Gaius Mulley
Subject: Re: gettimeofday failing
Date: Wed, 29 May 2024 19:47:11 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/28.2 (gnu/linux)

une <une@fastmail.fm> writes:

> Hi.
>
> I'm new to modula2. I tried to compile the following code on my debian-x86_64:
>
> ```
> MODULE hello5;
>
> FROM StrIO IMPORT WriteString, WriteLn;
> FROM NumberIO IMPORT WriteInt;
> FROM wraptime IMPORT timeval, InitTimeval, KillTimeval, gettimeofday, 
> timezone, InitTimezone, KillTimezone, localtime_r, tm, InitTM, KillTM, 
> GetYear, GetMonth, GetDay;
>
> VAR tv: timeval;
>     tz: timezone;
>     i: INTEGER;
>     m: tm;
>
> BEGIN
>
>     tv := InitTimeval();
>     tz := InitTimezone();
>     m  := InitTM();
>     i  := gettimeofday(tv, tz);
>     m  := localtime_r(tv, m);
>     
>     WriteString("i = ");
>     WriteInt(i, 0);
>     WriteLn;
>     WriteString("Year = ");
>     WriteInt(GetYear(m), 0);
>     WriteLn;
>     WriteString("Month = ");
>     WriteInt(GetMonth(m), 0);
>     WriteLn;
>     WriteString("Day = ");
>     WriteInt(GetDay(m), 0);
>     WriteLn;
>
>     m  := KillTM(m);
>     tv := KillTimeval(tv);
>     tz := KillTimezone(tz);
> END hello5.
> ```
>
> Compiler version:
> $ gm2 --version
> gm2 (Debian 12.2.0-14) 12.2.0
>
> Compilation result: success.
> Execution result:
> `
> i = -1
> Year = -1
> Month = -1
> Day = -1
> `
>
> Then I tried gm2/gcc-14.1.0 built from the release tarball.
> $ gm2 --version
> gm2 (GCC) 14.1.0
>
> Compilation result: success.
> Execution result:
> `
> RTExceptions.mod:650:35: In invalidloc
> RTExceptions.mod:650:35:invalid address referenced
> Aborted
> `
>
> A quick look at wraptime.cc it appears that my system is failing at 
> `HAVE_STRUCT_TIMEZONE` and `HAVE_STRUCT_TM`.
>
> I handcoded
> #define HAVE_STRUCT_TIMEZONE 1
> #define HAVE_STRUCT_TM 1
> and rebuilt. I'm aware that hardcoding is not a good practice, it's just 
> quick test.
>
> Execution result:
> `
> i = 0
> Year = 124
> Month = 4
> Day = 28
> `
>
> 👍
>
> Carlos.

Hi Carlos,

now fixed in the gcc git repository development branch.
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115276

thanks for the bug report,

regards,
Gaius



reply via email to

[Prev in Thread] Current Thread [Next in Thread]