Opened 14 years ago

Closed 14 years ago

#2551 closed Bugs (fixed)

date_time's embedded constrained_value uses uninitialized member

Reported by: Brad Spencer <spencer@…> Owned by: az_sw_dude
Milestone: Boost 1.38.0 Component: date_time
Version: Boost 1.37.0 Severity: Problem
Keywords: Cc: spencer@…

Description

At first I thought this was a spurious warning from gcc-4.3, but upon further inspection, I agree that the constrained_value class that comes as part of date_time is using its value_ member before initializing it when constructed with an out-of-range value.

I checked what the unofficial Boost Constrained Value proposed library does, and it seems to "initialize, then check". It's reality easy to apply the same approach here (see the attached patch). There may be a better approach overall, but this prevents value_'s value from being passed to a function (even if that function "doesn't use" the value) before it is initialized.

Attachments (1)

50-date_time-constrained_value-uninitialized.diff (476 bytes ) - added by Brad Spencer <spencer@…> 14 years ago.

Download all attachments as: .zip

Change History (2)

by Brad Spencer <spencer@…>, 14 years ago

comment:1 by Andrey Semashev, 14 years ago

Resolution: fixed
Status: newclosed

Already fixed in trunk.

Note: See TracTickets for help on using tickets.