stan-dev/stan — pull request #672 by mitzimorris (2014-05-28 22:39:58+00:00)
Title: Bugfix/670 io check too large ints

#### Summary:

Modified class dump_reader in stan/io/dump.hpp so that it throws exceptions when data values read in from a file in S-plus dump format exceed the min/max int and double values.

#### Intended Effect:

Provide more informative error diagnostics to Stan users.
Current behaviour is that the data_reader fails silently when it encounters a variable with bad data values and returns a var_context object that doesn't contain the variable. Requests for the variable result in an exception with error message saying unknown variable.
Now data_reader throws an exception that gives the variable name and type of error.

#### How to Verify:

a. Additional tests have been added to the unit tests src/test/io/dump_test.cpp

b. Tested by running command stan from the command line using the example in src/model/basic_estimators/bernoulli.stan and introducing errors into the variable definitions in the bernoulli.data.R file, e.g.,
changing N <- 10 to N <- 109999999999999999999999999999999999
Compiling the model and running it on the bad data file results in error message:
Exception: variable N error: value 109999999999999999999999999999999999 beyond int range
Diagnostic information:
src/stan/io/dump.hpp(869): Throw in function bool stan::io::dump_reader::next()
Dynamic exception type: boost::exception_detail::clone_impl >
std::exception::what: variable N error: value 109999999999999999999999999999999999 beyond int range

#### Side Effects:

Syntax checks for close parens on R sequence and structure statements may cause problems for existing data.R files which were ill-formed but allowed by the parser.

#### Documentation:

No documentation for users.

#### Reviewer Suggestions:

Daniel Lee?