I am currently intending to
work with M2PP (https://github.com/m2sf/m2pp), and for this
purpose I have been writing a Makefile to compile all of the
components and build the preprocessor. I have run the
configuration script (using the settings for ISO, GNU, POSIX,
32/64) and started preparing the make targets for the individual
sub-modules.
However, I have come across a surprising problem: several constant
initializations are being flagged as involving one or more
variables. I have confirmed that the assignments in question are,
in fact, constant, but the compiler is saying that they aren't.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src/imp/Hash.mod:34:13:
error: In implementation module ‘Hash’: in assignment, cannot
assign a variable to a constant ‘BitsInUse’
34 | BitsInUse =
| ^
src/imp/Hash.mod:34:3: error: designator ‘BitsInUse’ is declared
as a CONST
34 | BitsInUse =
| ^~~~~~~~~
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
I have confirmed that both AddressableBits and MaxBits are constants, and the application of +, *, and
ORD() on constants clearly should be
recognized as constants as well. Indeed, immediately following
this initialization is the constant declaration
(I am assuming that ORD(FALSE) should return zero, and ORD(TRUE) should return
one, which it clearly is the intended use in this code - in
effect, a pocket ternary _expression_ that only works with numeric
values.)
I noted that the error message does not specify the supposed
variable in question, which would make it harder to debug even if
there were a variable in the assignment.
Am I missing something? I am not inclined to assume that this is a
compiler fault, but if it isn't, I am not certain why it would see
a variable in these assignments.