FhSim  3.1.0
Marine systems simulation
Loading...
Searching...
No Matches
0115 — The FMU exporter reads `Size_<port>` with `std::stoi`, so `Size_y="2x"` reads 2
ID 0115
Class BUG
Severity 1
Status ready

Models: —

Found: 2026-10-25, plan Q1 (r2-wrong-numbers), observation 13.

Evidence

src/fmu/fhFMUexport/FmuPortMappingReader.cpp:163: const int portSize = std::stoi(obj.Attribute("Size_" + portName));. stoi reads a numeric prefix, so Size_y="2x" gives 2 and Size_y="2.7" gives 2. A missing or non-numeric value throws std::invalid_argument without naming the object or port. The engine reads the same attribute strictly.

Effect

An exported FMU with a port of the wrong size from a mistyped input, with no message.

Possible fix

Parse with fhsim::strict (as Initial_ values now are, FHSIM-0112), require a whole number of 1 or more, and name the object, port and text in the error.

Test that would prove it

In tests/fmu/FmuPortMappingReader_test.cpp: Size_y="2x" throws std::runtime_error naming ExtLink, y and 2x.

Risk

Low. No consumer exports an FMU.