bugmake - Bugs: bug #16788, 'ORDINARY_MTIME_MAX' macro causes...

 
 

bug #16788: 'ORDINARY_MTIME_MAX' macro causes integral constant overflow

Submitter:  None
Submitted:  Thu 08 Jun 2006 07:09:44 PM UTC
   
 
Severity:  3 - Normal Item Group:  Enhancement
Status:  Fixed Privacy:  Public
Assigned to:  None Open/Closed:  Closed
Component Version:  3.81 Operating System:  MS Windows
Fixed Release:  None Triage Status:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Tue 03 Jan 2023 02:53:22 PM UTC, comment #5: 

I always do my compilation on Windows using straight MSVC.  I don't have any cygwin or mingw compiler installed there.  I don't own a license for Windows so I use the developer download to run it in a VM; this expires every 90 days so I only do the most minimal setup on it and the developer VM comes with MSVC pre-installed.

Admittedly it's the newest version of MSVC; maybe an older version would throw a warning.

Paul D. Smith <psmith>
Group administrator
Tue 03 Jan 2023 12:25:48 PM UTC, comment #4: 

With what compiler? The original warning seems to be from MSVC or maybe something else, but not from GCC.

Eli Zaretskii <eliz>
Group Member
Tue 03 Jan 2023 07:28:08 AM UTC, comment #3: 

I don't see any warnings in the current builds on Windows, so I guess this was resolved?

Paul D. Smith <psmith>
Group administrator
Tue 22 Oct 2013 04:25:47 PM UTC, comment #2: 

Paul (Eggert) provided these macros; they are intended to work properly in various endianness, sizeof(int), sizeof(uintmax_t), etc. environments.  There's something a little tricky about them related to overflow handling, in order to cause compile-time decisions instead of run-time decisions I think, but I can't remember what it is.  The ChangeLog.2 entry at 2000-06-10 has a few details.  I think this is probably OK but I'd like to look at it again and make sure I understand what's going on.

Paul D. Smith <psmith>
Group administrator
Tue 22 Oct 2013 04:09:02 PM UTC, comment #1: 

Paul,

The OP suggests to replace this:

#define ORDINARY_MTIME_MAX ((FILE_TIMESTAMP_S (NEW_MTIME) \
                             << FILE_TIMESTAMP_LO_BITS) \
                            + ORDINARY_MTIME_MIN + FILE_TIMESTAMPS_PER_S - 1)

with this:

#define ORDINARY_MTIME_MAX ((FILE_TIMESTAMP_S (NEW_MTIME) \
                             << FILE_TIMESTAMP_LO_BITS) \
                            + ORDINARY_MTIME_MIN - 1 + FILE_TIMESTAMPS_PER_S)

(in filedef.h).

This looks as a no-brainer to me, so if you don't object, I will make that change.

Eli Zaretskii <eliz>
Group Member
Thu 08 Jun 2006 07:09:44 PM UTC, original submission:  

Abstract: The macro causes a compiler warning.  Workaround: rearrange the additions.  The details are attached in XML below.

<bug-report>
<behaviour>
<location path="make-3.81/file.c" line="775">
FILE_TIMESTAMP_S (ORDINARY_MTIME_MAX)
</location>
<output>
warning C4307: '+' : integral constant overflow
</output>
</behaviour>
<reason>
The warning is caused by the addition (FILE_TIMESTAMP_S (NEW_MTIME) &lt;&lt; FILE_TIMESTAMP_LO_BITS) + ORDINARY_MTIME_MIN + FILE_TIMESTAMPS_PER_S
</reason>
<remedy>
<location path="make-3.81/filedef.h" line="188">
#define ORDINARY_MTIME_MAX ((FILE_TIMESTAMP_S (NEW_MTIME) \
     &lt;&lt; FILE_TIMESTAMP_LO_BITS) \
    + ORDINARY_MTIME_MIN - 1 + FILE_TIMESTAMPS_PER_S)
</location>
</remedy>
</bug-report>

Anonymous

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by psmith (Posted a comment)
  • -email is unavailable- added by eliz (Posted a comment)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only logged-in users can vote.

     

    Follow 2 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2023-01-03 psmith StatusNone Fixed
        Open/ClosedOpen Closed

    Back to the top

    Powered by Savane 3.13-3230.
    Corresponding source code