Nonlegacy ExponentList constructors use legacy length words
Nobody has claimed this yet.
- Dominant language
- Macaulay2
- Stars
- 435
- Forks
- 297
- Avg merge
- 4d 20h
- Merged PRs (30d)
- 11
Description
`ExponentList` interprets its first word as the number of variable/exponent pairs: `length(m) = 2*m[0]+1`. However, `one` and `var` in `M2/Macaulay2/e/monomials/ExponentList.hpp` always write legacy total-length words.
```cpp
using Ops = ExponentList; // also occurs for int,false
Ops::Vector output;
Ops::one(output); // expected [0]; actual [1]
Ops::var(2, 3, output); // expected [1,2,3]; actual [3,2,3]
Ops::var(2, 0, output); // expected [0]; actual [1]
```
Readers consequently interpret these allocations as larger than their actual sizes, potentially reading beyond the end. The representations are aliased by f4/varpower-monomial.hpp and schreyer-resolutions/res-monomial-types.hpp.
Reproduced by checking output size and the first word, without dereferencing beyond its allocation, in direct typed engine tests at c156fdcba4 (Apple Clang 21). No production changes.
### Failing unit-test blocks
- `TYPED_TEST(ExponentListNonlegacy, DISABLED_constructorLengthConvention)` in `M2/Macaulay2/e/unit-tests/ExponentListTest.cpp`.
This typed block fails for both `ExponentList` and `ExponentList` (instances `/0` and `/1`).
These regressions were explicitly run and confirmed to fail against the current implementation. They assert the intended corrected behavior and remain disabled in normal runs until the defect is fixed.
Run from the CMake build directory after building `M2-unit-tests`:
```sh
./Macaulay2/e/M2-unit-tests \
--gtest_also_run_disabled_tests \
--gtest_filter='ExponentListNonlegacy/*.DISABLED_constructorLengthConvention'
```
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Inspect one and var in M2/Macaulay2/e/monomials/ExponentList.hpp, then read the disabled typed test in M2/Macaulay2/e/unit-tests/ExponentListTest.cpp. Run the provided M2-unit-tests command for ExponentListNonlegacy/*.DISABLED_constructorLengthConvention; done means both int,false and long,false instances pass with the nonlegacy length convention.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cmake, cpp
- Domain
- backend, testing-qa
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Active
- Clarity
- Clearly specified
- Newbie friendliness
- 78/100