Repository navigation
Construct static and preallocated arrays without the allocating vector runtime #561
lexx42xxel
started this conversation in
Ideas
Replies: 1 comment
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Summary
This is aimed at embedded real-time code, where building without exception
handling and without dynamic memory allocation is standard practice (coding
guidelines for such code commonly prohibit both).
TASKING uses the EDG front end in its compiler toolchains for safety-critical
embedded systems, and would like to contribute this and related fixes to the
EDG project on GitHub.
In such programs, construction of arrays with static, automatic or
otherwise preallocated storage is still lowered to calls into the vector
runtime (
__edg_vec_ctorand friends inlib_src/vec_newdel.c), whichalso contains the allocating
new[]/delete[]support. A program thatnever allocates therefore still links the allocation code.
Proposal
construction loop (nested loops for multidimensional arrays) instead of
a runtime call (
src/lower_init.c).(
lib_src/vec_preallocated.c), so programs compiled without exceptionhandling that do not use array new no longer link the allocating
runtime. With exception handling the unwinder's array cleanup still
lives in the allocating runtime, so it is still linked. The allocating
entry points and their exception behaviour are unchanged.
for arrays of empty classes, the innermost elements (rows may have size
zero in the generated C).
doc/source/lower_il.rst(exception handling itself still allocates; newly generated calls need
the matching runtime library).
Notes
Version: EDG C/C++ front end 7.0, main at commit
6a6c7f2d6bd8027f1b0c90877b4ba222fbff6642(2026-11-15).While implementing and testing this, eleven pre-existing bugs in array
construction, array new/delete and VLA initialization were found. They are
filed separately and fixed independently of this change:
= {}does not zero a VLA of a class with a destructor (no EH)Implementation is ready (8 commits, on top of the fix for #557, #558, #559
and #554),
with regression tests
tests/tests/regressions/array-construction-*.sft.cpp.All reactions