Opened 11 years ago

Closed 11 years ago

#5807 closed Bugs (fixed)

Debug build of the program asserts calling iscntrl(c) in boost::spirit::detail::token_printer_debug_for_chars::print(), with c == -127

Reported by: Stephen Torri <stephen.torri@…> Owned by: Joel de Guzman
Milestone: To Be Determined Component: spirit
Version: Boost 1.47.0 Severity: Problem
Keywords: Cc:

Description

When using a hexidecimal string that contains a negative value with the attached parser causes an assert to be thrown when calling iscntrl(c) in boost::spirit::detail::token_printer_debug_for_chars::print(), with c == -127. Disabling debug output allows the program to succeed and produce the following output:

successfully parsed 33026 772

Attached is a sample program that causes the error. The program was tested with Visual Studio 2010 (SP1) and Visual Studio 2008 (Boost 1.45).

Attachments (1)

test.cpp (3.0 KB ) - added by Stephen Torri <stephen.torri@…> 11 years ago.
Standalone program that exposes the assert in iscntrl

Download all attachments as: .zip

Change History (3)

by Stephen Torri <stephen.torri@…>, 11 years ago

Attachment: test.cpp added

Standalone program that exposes the assert in iscntrl

comment:1 by anonymous, 11 years ago

I changed boost/spirit/home/support/attributes.hpp at line 950 to be:

else if ( c >= 0 && c < 127 && iscntrl(c))

o << "
" << std::oct << static_cast<int>(c);

I read that the windows api expects that to be a value within the range of 0x00 - 0x1F or 0x7F despite the fact that the input parameter type for that function is a regular integer. The linux api also uses a int. So we cannot rely on the type checking to save us here. We have to constrain the range of values for 'c' to be within the range of 0 and 126.

Stephen

comment:2 by Joel de Guzman, 11 years ago

Resolution: fixed
Status: newclosed
Note: See TracTickets for help on using tickets.