Problem
Summary
When an array variable is initialized from a brace list of integer literals
whose values span more than one C++ integer rank (some fit in int, some
require long/long long), the generated IEC_ARRAY_1D constructor call fails
template argument deduction. strucpp codegen succeeds, but the resulting C++
does not compile.
Environment
- STruC++ version: 0.6.2, runtime
iec_array.hpp
- C++ compiler: g++ (MSYS2 UCRT64) 15.1.0,
-std=c++17
Impact
Compilation fails.
Reproduction
arr1d.st:
FUNCTION_BLOCK FB
VAR
seeds : ARRAY [0..3] OF UDINT := [5489, 1301868182, 2938499221, 2950281878];
END_VAR
END_FUNCTION_BLOCK
PROGRAM PLC_PRG
VAR
inst : FB;
r : UDINT;
END_VAR
inst();
r := inst.seeds[0];
END_PROGRAM
strucpp arr1d.st -o arr1d.cpp --no-default-libs
g++ -std=c++17 -I<strucpp>/runtime/include -c arr1d.cpp
(2938499221 and 2950281878 exceed INT_MAX; 5489 does not.)
Actual result
strucpp reports Compilation successful! and emits, in the FB constructor:
: SEEDS({5489, 1301868182, 2938499221, 2950281878})
g++ then fails:
arr1d.cpp:57:7: error: no matching function for call to
'strucpp::IEC_ARRAY_1D<strucpp::IECVar<unsigned int>, strucpp::ArrayBounds<0, 3> >
::IEC_ARRAY_1D(<brace-enclosed initializer list>)'
57 | : SEEDS({5489, 1301868182, 2938499221, 2950281878})
iec_array.hpp:63: note: candidate: 'template<class U> IEC_ARRAY_1D(std::initializer_list<U>)'
iec_array.hpp:63: note: template argument deduction/substitution failed:
arr1d.cpp:57: note: deduced conflicting types for parameter '_Tp' ('int' and 'long long int')
std::initializer_list<U> must deduce a single U; because 5489 is typed
int and the larger values are typed long long, deduction fails.
Code Locations
No response
Fix
No response
Acceptance
The array constant compiles regardless of the individual literals' natural C++
ranks — every element belongs to the array's declared element type (UDINT).
Problem
Summary
When an array variable is initialized from a brace list of integer literals
whose values span more than one C++ integer rank (some fit in
int, somerequire
long/long long), the generatedIEC_ARRAY_1Dconstructor call failstemplate argument deduction.
strucppcodegen succeeds, but the resulting C++does not compile.
Environment
iec_array.hpp-std=c++17Impact
Compilation fails.
Reproduction
arr1d.st:(
2938499221and2950281878exceedINT_MAX;5489does not.)Actual result
strucppreportsCompilation successful!and emits, in theFBconstructor:g++ then fails:
std::initializer_list<U>must deduce a singleU; because5489is typedintand the larger values are typedlong long, deduction fails.Code Locations
No response
Fix
No response
Acceptance
The array constant compiles regardless of the individual literals' natural C++
ranks — every element belongs to the array's declared element type (
UDINT).