Opened 9 years ago

#9764 new Feature Requests

posix_time::time_duration::operator/(int) can trigger division by zero error

Reported by: Michał Ślizak <michal.slizak+boost@…> Owned by: az_sw_dude
Milestone: To Be Determined Component: date_time
Version: Boost Release Branch Severity: Problem
Keywords: Cc:

Description

When dividing time_duration by a 64-bit integer the divisor will be implicitly cast to 'int' type (32-bits on most platforms).

This will cause 'division by zero' runtime error for any value which is a multiple of 232. It will also cause invalid values to be calculated if the divisor is larger than 231 - 1.

I don't see any reason why the time_duration interface should be limited to division by 32-bit integer values on systems where the storage type used in time_duration is at least 64-bit long.

Attachments (1)

time_duration_problem.cpp (486 bytes ) - added by Michał Ślizak <michal.slizak+boost@…> 9 years ago.
Reproduction

Download all attachments as: .zip

Change History (1)

by Michał Ślizak <michal.slizak+boost@…>, 9 years ago

Attachment: time_duration_problem.cpp added

Reproduction

Note: See TracTickets for help on using tickets.