Const arrays, and fuzzing of array constructors #883
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This change does two things:
(1) It corrects the way that qualifiers (in particular const) are
interpreted when applied to array types. A declaration:
const int v[2] = ...;
should be regarded as having type:
QualifiedType(ArrayType(int, 2), CONST)
but was being regarded as having type:
ArrayType(QualifiedType(int, CONST), 2)
(2) It changes the way array constructor expressions are fuzzed.
Previously, an array constructor for an array of size 256 was fuzzed
by trying to make 256 distinct expressions. The chances of the fuzzer
getting stuck and generating a "fuzzed into a corner" exception were
very high in such cases. This change uses an approach with a much
lower probability of failure, whereby a number of element constructor
expressions are generated and then re-used several times at random if
there are not enough to provide a value for every element of the
array.