olabusayoT commented on code in PR #1337:
URL: https://github.com/apache/daffodil/pull/1337#discussion_r1797471165
##########
daffodil-runtime1/src/main/scala/org/apache/daffodil/runtime1/processors/parsers/BinaryNumberParsers.scala:
##########
@@ -166,7 +166,22 @@ abstract class BinaryIntegerBaseParser(
def parse(start: PState): Unit = {
val nBits = getBitLength(start)
- if (nBits == 0) return // zero length is used for outputValueCalc often.
+ // minimum length for a signed binary integer is 2 bits, for unsigned it
is 1 bit
+ if (signed && nBits < 2) {
+ PE(
+ start,
+ "Minimum length for a signed binary integer is 2 bits, number of bits
%d out of range.",
+ nBits
+ )
+ return
+ } else if (!signed && nBits < 1) {
+ PE(
+ start,
+ "Minimum length for an unsigned binary integer is 1 bit, number of
bits %d out of range.",
+ nBits
+ )
+ return
+ }
if (primNumeric.width.isDefined) {
val width = primNumeric.width.get
if (nBits > width)
Review Comment:
Indeed it is, created DAFFODIL-2942
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]