Opened 13 years ago

Closed 12 years ago

#3418 closed Bugs (fixed)

phoenix/starter_kit: broken is_odd

Reported by: olafvdspek@… Owned by: Joel de Guzman
Milestone: Boost 1.41.0 Component: spirit
Version: Boost 1.40.0 Severity: Problem
Keywords: Cc:

Description

is_odd is broken for negative ints.

Change History (2)

comment:1 by Steven Watanabe, 13 years ago

Details:

From 5.6 "If both operands are nonnegative then the remainder is nonnegative; if not, the sign of the remainder is implementation-defined."

The implementation is

bool
is_odd(int arg1)
{
    return arg1 % 2 == 1;
}

The correct test is

bool
is_odd(int arg1)
{
    return arg1 % 2 != 0;
}

comment:2 by Joel de Guzman, 12 years ago

Resolution: fixed
Status: newclosed

fixed

Note: See TracTickets for help on using tickets.