Opened 11 years ago

Closed 11 years ago

#5776 closed Bugs (fixed)

program_options should understand "inf" and "nan"

Reported by: Rhys Ulerich <rhys.ulerich@…> Owned by: Vladimir Prus
Milestone: Boost 1.48.0 Component: program_options
Version: Boost 1.46.1 Severity: Problem
Keywords: Cc:

Description

program_options does not accept NaN or Inf as valid double input. This problem seems like it will be fixed automatically when #5689 arrives in 1.48. I am setting the milestone accordingly.

Recreate: the following sequence modifies the "Getting Started" first.cpp to accept double input:

   cp $BOOST_SOURCE/libs/program_options/example/first.cpp .
   perl -pi -e 's/<int>/<double>/;' first.cpp
   LDFLAGS="-lboost_program_options" make first # ...or whatever

The modified example indeed barfs on NaN or Inf input:

   $ ./first --compression=5.5
   Compression level was set to 5.5.

   $ ./first --compression=Inf
   error: in option 'compression': invalid option value 'Inf'

   $ ./first --compression=NaN
   error: in option 'compression': invalid option value 'NaN'

Change History (1)

comment:1 by Vladimir Prus, 11 years ago

Resolution: fixed
Status: newclosed

This indeed appears to be fixed automatically due to lexical_cast fixes. The example in the issue works for me on SVN HEAD.

Note: See TracTickets for help on using tickets.