kaitai_struct_compiler icon indicating copy to clipboard operation
kaitai_struct_compiler copied to clipboard

C++: Use unsigned size type for loop index

Open johnbeard opened this issue 8 months ago • 1 comments

This avoids a wrong sign conversion when the loop expression casts to a negative signed int.

Fixes: https://github.com/kaitai-io/kaitai_struct/issues/1220


I did intend to add a test for this based on the reproducing case in the linked issue, but I could not figure out how to actually run the tests.

I tried build-tests cpp_stl in the tests repo, but it errored out with complaints about Julia(?):

[error] /home/john/src/kaitai_struct/tests/translator/src/main/scala/io/kaitai/struct/testtranslator/specgenerators/JuliaSG.scala:6:8: object JuliaCompiler is not a member of package io.kaitai.struct.languages
[error] did you mean JavaCompiler or LuaCompiler?
[error] import _root_.io.kaitai.struct.languages.JuliaCompiler

How can I build/run the tests? I'll be more than happy to add a test if I know how!

johnbeard avatar Mar 14 '25 15:03 johnbeard

I figured out adding a test: https://github.com/kaitai-io/kaitai_struct_tests/pull/133

johnbeard avatar Mar 16 '25 02:03 johnbeard