File tree Expand file tree Collapse file tree 4 files changed +12
-5
lines changed
regression/cbmc/object-bits-parsing Expand file tree Collapse file tree 4 files changed +12
-5
lines changed Original file line number Diff line number Diff line change 11CORE
22test.c
33--object-bits foobar
4+ Value of "foobar" given for object-bits is not a valid unsigned integer.
45object-bits must be positive and less than the pointer width
56^EXIT=1$
67^SIGNAL=0$
Original file line number Diff line number Diff line change 11CORE
22test.c
33--object-bits 65
4+ Value of "65" given for object-bits is out of range.
45object-bits must be positive and less than the pointer width
56^EXIT=1$
67^SIGNAL=0$
Original file line number Diff line number Diff line change 11CORE
22test.c
33--object-bits 0
4+ Value of "0" given for object-bits is out of range.
45object-bits must be positive and less than the pointer width
56^EXIT=1$
67^SIGNAL=0$
Original file line number Diff line number Diff line change @@ -776,14 +776,18 @@ configt::bv_encodingt parse_object_bits_encoding(
776776 const std::string &argument,
777777 const std::size_t pointer_width)
778778{
779- const auto object_bits = string2optional<unsigned int >(argument);
780- if (!object_bits || *object_bits <= 0 || *object_bits >= pointer_width)
781- {
779+ const auto throw_for_reason = [&](const std::string &reason) {
782780 throw invalid_command_line_argument_exceptiont (
783- " object-bits must be positive and less than the pointer width (" +
781+ " Value of \" " + argument + " \" given for object-bits is " + reason +
782+ " . object-bits must be positive and less than the pointer width (" +
784783 std::to_string (pointer_width) + " ) " ,
785784 " --object_bits" );
786- }
785+ };
786+ const auto object_bits = string2optional<unsigned int >(argument);
787+ if (!object_bits)
788+ throw_for_reason (" not a valid unsigned integer" );
789+ if (*object_bits <= 0 || *object_bits >= pointer_width)
790+ throw_for_reason (" out of range" );
787791
788792 configt::bv_encodingt bv_encoding;
789793 bv_encoding.object_bits = *object_bits;
You can’t perform that action at this time.
0 commit comments