public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug modula2/115276] New: libgm2 wraptime.InitTM returns NIL
@ 2024-05-29 13:33 gaius at gcc dot gnu.org
  2024-05-29 13:38 ` [Bug modula2/115276] " gaius at gcc dot gnu.org
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: gaius at gcc dot gnu.org @ 2024-05-29 13:33 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115276

            Bug ID: 115276
           Summary: libgm2 wraptime.InitTM returns NIL
           Product: gcc
           Version: 15.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: modula2
          Assignee: gaius at gcc dot gnu.org
          Reporter: gaius at gcc dot gnu.org
  Target Milestone: ---

As reported on the gm2 mailing list the following code fails:


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.

reproduced by building gm2 trunk using:

Configured with: ../configure --prefix=/home/gaius/opt --disable-bootstrap
--disable-multilib --enable-languages=m2

$ gm2 -g hello5.mod
$ ./a.out

(On a debian x86_64 release 12 system)

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug modula2/115276] libgm2 wraptime.InitTM returns NIL
  2024-05-29 13:33 [Bug modula2/115276] New: libgm2 wraptime.InitTM returns NIL gaius at gcc dot gnu.org
@ 2024-05-29 13:38 ` gaius at gcc dot gnu.org
  2024-05-29 15:27 ` gaius at gcc dot gnu.org
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: gaius at gcc dot gnu.org @ 2024-05-29 13:38 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115276

Gaius Mulley <gaius at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
     Ever confirmed|0                           |1
   Last reconfirmed|                            |2024-05-29
             Status|UNCONFIRMED                 |ASSIGNED

--- Comment #1 from Gaius Mulley <gaius at gcc dot gnu.org> ---
Confirmed - it appears that wraptime.InitTM returns NIL causing gettimeofday to
fail.

It seems to me that libgm2/libm2iso/wraptime.cc:InitTM should use the macro
HAVE_SYS_TIME_H from re-reading the autoconf documentation:

https://www.gnu.org/software/autoconf/manual/autoconf-2.60/autoconf.html

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug modula2/115276] libgm2 wraptime.InitTM returns NIL
  2024-05-29 13:33 [Bug modula2/115276] New: libgm2 wraptime.InitTM returns NIL gaius at gcc dot gnu.org
  2024-05-29 13:38 ` [Bug modula2/115276] " gaius at gcc dot gnu.org
@ 2024-05-29 15:27 ` gaius at gcc dot gnu.org
  2024-05-29 16:27 ` cvs-commit at gcc dot gnu.org
  2024-05-29 18:37 ` gaius at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: gaius at gcc dot gnu.org @ 2024-05-29 15:27 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115276

--- Comment #2 from Gaius Mulley <gaius at gcc dot gnu.org> ---
Created attachment 58310
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=58310&action=edit
Proposed fix

Here is a proposed fix - currently bootstrapping and testing.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug modula2/115276] libgm2 wraptime.InitTM returns NIL
  2024-05-29 13:33 [Bug modula2/115276] New: libgm2 wraptime.InitTM returns NIL gaius at gcc dot gnu.org
  2024-05-29 13:38 ` [Bug modula2/115276] " gaius at gcc dot gnu.org
  2024-05-29 15:27 ` gaius at gcc dot gnu.org
@ 2024-05-29 16:27 ` cvs-commit at gcc dot gnu.org
  2024-05-29 18:37 ` gaius at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2024-05-29 16:27 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115276

--- Comment #3 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Gaius Mulley <gaius@gcc.gnu.org>:

https://gcc.gnu.org/g:d1a1f7e9f0bedea55c558ab95127679bc3e9ff72

commit r15-909-gd1a1f7e9f0bedea55c558ab95127679bc3e9ff72
Author: Gaius Mulley <gaiusmod2@gmail.com>
Date:   Wed May 29 17:26:59 2024 +0100

    PR modula2/115276 bugfix libgm2 wraptime.InitTM returns NIL

    This patch fixes libgm2/libm2iso/wraptime.cc:InitTM so that
    it does not always return NULL.  The incorrect autoconf macro
    was used (inside InitTM) and the function short circuited
    to return NULL.  The fix is to use HAVE_SYS_TIME_H and use
    AC_HEADER_TIME in libgm2/configure.ac.

    libgm2/ChangeLog:

            PR modula2/115276
            * config.h.in: Regenerate.
            * configure: Regenerate.
            * configure.ac: Use AC_HEADER_TIME.
            * libm2iso/wraptime.cc (InitTM): Check HAVE_SYS_TIME_H
            before using struct tm to obtain the size.

    gcc/testsuite/ChangeLog:

            PR modula2/115276
            * gm2/isolib/run/pass/testinittm.mod: New test.

    Signed-off-by: Gaius Mulley <gaiusmod2@gmail.com>

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug modula2/115276] libgm2 wraptime.InitTM returns NIL
  2024-05-29 13:33 [Bug modula2/115276] New: libgm2 wraptime.InitTM returns NIL gaius at gcc dot gnu.org
                   ` (2 preceding siblings ...)
  2024-05-29 16:27 ` cvs-commit at gcc dot gnu.org
@ 2024-05-29 18:37 ` gaius at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: gaius at gcc dot gnu.org @ 2024-05-29 18:37 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115276

Gaius Mulley <gaius at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |FIXED
             Status|ASSIGNED                    |RESOLVED

--- Comment #4 from Gaius Mulley <gaius at gcc dot gnu.org> ---
Closing now the testsuite has passed and patch has been applied.

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2024-05-29 18:37 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-05-29 13:33 [Bug modula2/115276] New: libgm2 wraptime.InitTM returns NIL gaius at gcc dot gnu.org
2024-05-29 13:38 ` [Bug modula2/115276] " gaius at gcc dot gnu.org
2024-05-29 15:27 ` gaius at gcc dot gnu.org
2024-05-29 16:27 ` cvs-commit at gcc dot gnu.org
2024-05-29 18:37 ` gaius at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).