You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@daffodil.apache.org by "mbeckerle (via GitHub)" <gi...@apache.org> on 2023/03/01 17:46:28 UTC

[GitHub] [daffodil] mbeckerle commented on a diff in pull request #974: Add checks for bit lengths

mbeckerle commented on code in PR #974:
URL: https://github.com/apache/daffodil/pull/974#discussion_r1122110345


##########
daffodil-runtime1/src/main/scala/org/apache/daffodil/runtime1/processors/parsers/BinaryNumberParsers.scala:
##########
@@ -167,6 +167,16 @@ abstract class BinaryIntegerBaseParser(
   def parse(start: PState): Unit = {
     val nBits = getBitLength(start)
     if (nBits == 0) return // zero length is used for outputValueCalc often.
+    if (primNumeric.width.isDefined) {
+      val width = primNumeric.width.get
+      if (nBits > width)
+        PE(
+          start,

Review Comment:
   Yup. Poor-man's constant folding using an obvious hack - infoset to be a fake infoset that just throws if you try to access any method on it. Eval expression. No infoset access means it can compute the value. If it touches the infoset, it throws, and determines therefore that it can't constant-fold the expression.



-- 
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: commits-unsubscribe@daffodil.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org