public inbox for glibc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libc/12401] New: [PATCH] fix assertion in mktime.c
@ 2011-01-15 11:43 rmh at gnu dot org
  2011-01-15 11:43 ` [Bug libc/12401] " rmh at gnu dot org
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: rmh at gnu dot org @ 2011-01-15 11:43 UTC (permalink / raw)
  To: glibc-bugs

http://sourceware.org/bugzilla/show_bug.cgi?id=12401

           Summary: [PATCH] fix assertion in mktime.c
           Product: glibc
           Version: unspecified
            Status: NEW
          Severity: normal
          Priority: P2
         Component: libc
        AssignedTo: drepper.fsp@gmail.com
        ReportedBy: rmh@gnu.org


Created attachment 5195
  --> http://sourceware.org/bugzilla/attachment.cgi?id=5195
patch 1

The following assertion in mktime.c:

   verify (long_int_year_and_yday_are_wide_enough,
          INT_MAX <= LONG_MAX / 2 || TIME_T_MAX <= UINT_MAX);

is not satisfiable on any ILP32 architecture with 64-bit time_t.

I propose the following patch to fix the problem.  Given the purpose of this
assertion, I've split my patch in 3 to prove that it doesn't introduce any
regression.  Here's my semi-formal proof:

First let A be (INT_MAX <= LONG_MAX / 2).

  - Patch #1: This works on the assumption that for any value of LONG_MAX, the
whole function either works correctly or fails to compile. With my patch, if a
certain condition A is met, every instance of `long' type is replaced with
`time_t', and the assertion that checks for LONG_MAX now checks for TIME_T_MAX
in its place. It must remain true that for any value of TIME_T_MAX, the whole
function either works correctly or fails to compile, regardless of condition A.

  - Patch #2: If condition A is met, clearly the assertion will always suceed,
so it can be removed.

  - Patch #3: If condition A is met, the second assertion is skipped, which is
equivalent to making A one of its options.

(or in plain English, if longs are too short, time_ts can be used instead)

-- 
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.


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

end of thread, other threads:[~2014-06-27 12:28 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-01-15 11:43 [Bug libc/12401] New: [PATCH] fix assertion in mktime.c rmh at gnu dot org
2011-01-15 11:43 ` [Bug libc/12401] " rmh at gnu dot org
2011-01-15 11:44 ` rmh at gnu dot org
2011-01-15 11:47 ` rmh at gnu dot org
2011-01-15 16:13 ` drepper.fsp at gmail dot com
2014-06-27 12:28 ` fweimer at redhat dot com

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).